English Amiga Board twister effect
 Register Amiga FAQ Rules & Help Members List  /  Moderators List Today's Posts Mark Forums Read

 28 June 2011, 09:23 #1 Coagulus Gets there in the end...   Join Date: Sep 2005 Location: Wales Posts: 630 twister effect Hi all, One of my favourite demo effects is a vertical twisting and rotating oblong. I'm trying to recreate this (admittedly firstly on the PC using Blitz Basic but then maybe on the amiga later as I've re set up that under WinUAE). I've created what looks like the oblong out of a stack of 1-pixel-high horizonal lines which seems to rotate nicely when solid but when I tried warping it with sine curves and it just looks warped and not twisted. Is there a pseudocode (or readable code) which does this anywhere that I can look at? I'm not great at these demo effects (I've only nailed starfields and sine scrollers so far!) but my mate challenged me to write a demo in Blitz for the PC and later the Amiga. I shouldn't agree to things when drunk! Rob
 28 June 2011, 09:45 #2 StingRay move.l #\$c0ff33,throat   Join Date: Dec 2005 Location: Berlin/Joymoney Posts: 6,214 A twister is a rather simple effect. Create 4 points: x1 = sin(a) x2 = sin(a+90) x3 = sin(a+90*2) x4 = sin(a+90*3) Then you just connect these points, i.e. you draw a simple horizontal line from x1-x2;x2-x3;x3-x4;x4-x1. When you draw the lines, you have to check that xstart
 28 June 2011, 09:58 #3 8bitbubsy Registered User   Join Date: Sep 2009 Location: Norway Posts: 1,290 You also need a routine to fill the "fake sides" of the twister, so it looks like it is twisting and not just shrinking. Like this (for extra coolness, use the copperlist for gradient). http://cpcrulez.fr/im3/twist.png
28 June 2011, 10:00   #4
StingRay
move.l #\$c0ff33,throat

Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,214
Quote:
 Originally Posted by 8bitbubsy You also need a routine to fill the "fake sides" of the twister, so it looks like it is twisting and not just shrinking.
First question: what are "fake sides"?
Second question: What does a horizontal line drawer do?

 28 June 2011, 10:04 #5 8bitbubsy Registered User   Join Date: Sep 2009 Location: Norway Posts: 1,290 1. By "sides" I mean the two different regions, e.g. red being side 1, and dark red being side 2. Lousy way of putting it, but I'm sure you catch my drift? 2. It ... draws a filled line. My mistake. But at least you should have some routines to make it look gradient and fake 3D-ish, that's how real men do it Now I assume I get an answer like "You have no idea how to code a twister", which of course is more than correct, but it doesn't mean I don't know how cool twisters should look like in my opinion.
28 June 2011, 10:06   #6
StingRay
move.l #\$c0ff33,throat

Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,214
Quote:
 Originally Posted by 8bitbubsy 2. It ... draws a filled line. My mistake. But at least you should have some routines to make it look gradient and fake 3D-ish, that's how real men do it
He asked for a simple twister algorithm. That you can easily improve that very basic algorithm should be clear (draw textured lines, add light sources etc. pp.) but that is not exactly the topic here.

Edit since Mr. Bubsy edited his post:

Quote:
 Originally Posted by 8bitbubsy Now I assume I get an answer like "You have no idea how to code a twister", which of course is more than correct, but it doesn't mean I don't know how cool twisters should look like in my opinion.
You assume a lot of things. Also, you might want to think what is more helpful here, your post which mentions "fake sides" and other "interesting" things or a simple and easy to understand explanation of the basic twister algorithm.

Last edited by StingRay; 28 June 2011 at 10:50.

 28 June 2011, 10:18 #7 Coagulus Gets there in the end...   Join Date: Sep 2005 Location: Wales Posts: 630 my god, I was overcomplicating things immensely! My code was over the top, caused a nice warp, but didn't twist! Thanks. EDIT - It works, can't believe how simple it was. I've got to try and not find the complicated solutions! Last edited by Coagulus; 28 June 2011 at 10:37. Reason: tested
28 June 2011, 12:02   #8
Dunny
Registered User

Join Date: Aug 2006
Location: Scunthorpe/United Kingdom
Posts: 1,178
Quote:
 Originally Posted by Coagulus my god, I was overcomplicating things immensely! My code was over the top, caused a nice warp, but didn't twist! Thanks. EDIT - It works, can't believe how simple it was. I've got to try and not find the complicated solutions!
Can you post a code snippet? I'm curious as to how you did this

D.

28 June 2011, 12:32   #9
pmc
gone

Join Date: Apr 2007
Location: completely gone
Posts: 1,596
I made an asm twister a while ago now - it's held in my unreleased effects stockpile.

It's a bit more like the one from Hardwired in style rather than the type (I think) you mean but, well... it's still a twister

Quote:
 Originally Posted by Coagulus It works, can't believe how simple it was. I've got to try and not find the complicated solutions!
Nice one Coagulus.

Now time for your Amiga assembler version!

 28 June 2011, 14:03 #10 Coagulus Gets there in the end...   Join Date: Sep 2005 Location: Wales Posts: 630 well, the test was done in blitzplus for pc. It's not optimized and very wasteful, but a great basis for me to work on! Code: ```; twister test Global a# Global x1# Global x2# Global x3# Global x4# Global ang#=0 Global amp#=9 Graphics 800,600 Repeat Cls twister() Flip Until KeyDown(1) End Function twister() For a=1 To 500 Step 2 x1=((Sin((a/amp)+ang))*100)+300 x2=((Sin((a/amp)+ang+90))*100)+300 x3=((Sin((a/amp)+ang+90*2))*100)+300 x4=((Sin((a/amp)+ang+90*3))*100)+300 Color 255,0,0 If x1
 28 June 2011, 14:26 #11 pmc gone   Join Date: Apr 2007 Location: completely gone Posts: 1,596 Any chance of a .exe of that so the non-Blitz guys like me can see it in action...?
28 June 2011, 14:40   #12
StingRay
move.l #\$c0ff33,throat

Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,214
Quote:
 Originally Posted by Coagulus well, the test was done in blitzplus for pc. It's not optimized and very wasteful, but a great basis for me to work on!
Looks fine to me, have fun playing around with the code and improving twisty twister.

28 June 2011, 14:44   #13
Coagulus
Gets there in the end...

Join Date: Sep 2005
Location: Wales
Posts: 630
Quote:
 Originally Posted by StingRay Looks fine to me, have fun playing around with the code and improving twisty twister.
I shall, cheers!

As a test I tried to copy the code into Amiga Blitz Basic 2, odd thing is, I only changed the multipliers because of the resolution and now get an almost triangular one. I do suspect that a lot of optimizing will be needed for a miggy version in Blitz.

It's been a while since I used blitz on the Amiga though, I had to dig out my old yellow Blitz Basic 2 manual!

Code:
```VWait 200
BLITZ

Slice 0,44,320,256,\$fff8,2,8,4,320,320

BitMap 0,320,256,2
BitMap 1,320,256,2

bm=0

a.f=0
x1.f=0
x2.f=0
x3.f=0
x4.f=0
ang.f=0
amp.f=100
While Joyb(0)=0

VWait

Use BitMap bm
Cls 0

For a.f=1 To 200 Step 2
x1.f=((Sin((a.f/amp.f)+ang.f))*50)+140
x2.f=((Sin((a.f/amp.f)+ang.f+90))*50)+140
x3.f=((Sin((a.f/amp.f)+ang.f+90*2))*50)+140
x4.f=((Sin((a.f/amp.f)+ang.f+90*3))*50)+140

If x1<x2
Line x1,a,x2,a,1
End If

If x2<x3
Line x2,a,x3,a,2
End If

If x3<x4
Line x3,a,x4,a,3
End If

If x4<x1
Line x4,a,x1,a,1
End If
Next
ang=ang+0.1
If ang=360 Then ang=0

VWait
Show bm

bm=1-bm

Wend

End```
Quote:
 Originally Posted by pmc Any chance of a .exe of that so the non-Blitz guys like me can see it in action...?
ok

(esc quits)

http://coagulus.newport.net/t/twist.exe

Last edited by TCD; 28 June 2011 at 15:02. Reason: Back to back merged. Use the edit function.

 28 June 2011, 14:54 #14 pmc gone   Join Date: Apr 2007 Location: completely gone Posts: 1,596 Thanks Coagulus - looks nice I'd say I might have to knock up an Amiga asm version to complement the twister I already made before
28 June 2011, 15:02   #15
Dunny
Registered User

Join Date: Aug 2006
Location: Scunthorpe/United Kingdom
Posts: 1,178
Quote:
 Originally Posted by Coagulus well, the test was done in blitzplus for pc. It's not optimized and very wasteful, but a great basis for me to work on!
Very nice! Equivalent in SpecBAS (note that I've modified your use of "amp" to make it twist as it draws):

Code:
```10 REM Twister demo effect
20 LET ang=0: LET xoff=(SCRw/2)-20: LET aa=1
30 SCREEN LOCK
40 LET amp=SIN(aa)*16
50 FOR y=0 TO SCRh-1
60 LET x1=((SIN((y/amp)+ang))*100)+xoff
70 LET x2=((SIN((y/amp)+ang+90))*100)+xoff
80 LET x3=((SIN((y/amp)+ang+180))*100)+xoff
90 LET x4=((SIN((y/amp)+ang+270))*100)+xoff
100 IF x1<x2 THEN MOVE TO x1,y: DRAW INK 4; TO x2,y
110 IF x2<x3 THEN MOVE TO x2,y: DRAW INK 12; TO x3,y
120 IF x3<x4 THEN MOVE TO x3,y: DRAW INK 6; TO x4,y
130 IF x4<x1 THEN MOVE TO x4,y: DRAW INK 14; TO x1,y
140 NEXT y
150 INC ang,1,0 TO 359
160 INC aa
170 WAIT SCREEN
180 CLS
190 GO TO 40```

28 June 2011, 15:14   #16
Coagulus
Gets there in the end...

Join Date: Sep 2005
Location: Wales
Posts: 630
Quote:
 Originally Posted by Dunny Very nice! Equivalent in SpecBAS (note that I've modified your use of "amp" to make it twist as it draws):
that's cool! I've tried it in my code too.

ps nice looking language, reminds me of my first coding on the speccy!

 28 June 2011, 15:22 #17 dobbar   Posts: n/a Bring it up next time you're round, I'll be setting more challenges when we're drunk !
28 June 2011, 15:35   #18
Coagulus
Gets there in the end...

Join Date: Sep 2005
Location: Wales
Posts: 630
Quote:
 Originally Posted by dobbar Bring it up next time you're round, I'll be setting more challenges when we're drunk !
ah, the reason (culprit) for all this appears!

EDIT : and I challenge you to do the ASM version since your using it at the mo!

Last edited by Coagulus; 28 June 2011 at 15:39. Reason: return challenge

 28 June 2011, 16:05 #19 dobbar   Posts: n/a Challenge accepted ! (amount of time needed deliberatley not specified )
28 June 2011, 16:10   #20
8bitbubsy
Registered User

Join Date: Sep 2009
Location: Norway
Posts: 1,290
Quote:
 Originally Posted by StingRay Edit since Mr. Bubsy edited his post: You assume a lot of things. Also, you might want to think what is more helpful here, your post which mentions "fake sides" and other "interesting" things or a simple and easy to understand explanation of the basic twister algorithm.
Dear Mr. StingRay:
I assume a lot of things indeed, but I frankly don't know what answer I can expect from you, it's mostly picking on my errors in a rather annoying way.
As the thread is evolving and starting to be open for other ideas, my suggestions might as well be appopriate to this thread after all. And "fake sides" was not a very bad explaination, given there exists twisters with the feeling of 3D sides w/ fake light sources. Or should I say light sources? Real light sources, better?
The reason I say "fake" is because it's pure cheating, coding wise. It's like calling a dragonball a ball, code wise (like I did in #flashtro some years ago ). This is what I mean, and with some more maths you can create the feeling of different sides on the twister, like walls.

 Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 Similar Threads Thread Thread Starter Forum Replies Last Post bobster Coders. Tutorials 16 17 October 2012 12:11 Cherno request.UAE Wishlist 3 13 February 2012 06:26 mai support.Games 3 04 February 2010 12:58 absence Coders. General 13 02 April 2009 16:41 Six Coders. General 11 09 January 2007 15:45

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home News Main     Amiga scene     Retrogaming General Discussion     Nostalgia & memories Support     New to Emulation or Amiga scene         Member Introductions     support.WinUAE     support.WinFellow     support.OtherUAE     support.FS-UAE         project.AmigaLive     support.Hardware         Hardware mods         Hardware pics     support.Games     support.Demos     support.Apps     support.Amiga Forever     support.Amix     support.Other Requests     request.UAE Wishlist     request.Old Rare Games     request.Demos     request.Apps     request.Modules     request.Music     request.Other     Looking for a game name ?     Games images which need to be WHDified abime.net - Hall Of Light     HOL news     HOL suggestions and feedback     HOL data problems     HOL contributions abime.net - Amiga Magazine Rack     AMR news     AMR suggestions and feedback     AMR data problems     AMR contributions abime.net - Home Projects     project.Amiga Lore     project.EAB     project.IRC     project.Mods Jukebox     project.Wiki abime.net - Hosted Projects     project.aGTW     project.APoV     project.ClassicWB     project.Jambo!     project.Green Amiga Alien GUIDES     project.Maptapper     project.Sprites     project.WinUAE - Kaillera Other Projects     project.Amiga Demo DVD     project.Amiga Game Factory     project.CARE     project.EAB File Server     project.CD32 Conversion     project.Game Cover Art         GCA.Feedback and Suggestions         GCA.Work in Progress         GCA.Cover Requests         GCA.Usefull Programs         GCA.Helpdesk     project.KGLoad     project.MAGE     project.Missing Full Shareware Games     project.SPS (was CAPS)     project.TOSEC (amiga only)     project.WHDLoad         project.Killergorilla's WHD packs Misc     Amiga websites reviews     MarketPlace         Swapshop     Collections     EAB's competition Coders     Coders. General         Coders. Releases         Coders. Tutorials     Coders. Asm / Hardware     Coders. System         Coders. Scripting         Coders. Nextgen     Coders. Language         Coders. C/C++         Coders. AMOS         Coders. Blitz Basic     Coders. Contest         Coders. Entries Off Topic     OT - General     OT - Entertainment     OT - Sports     OT - Technical     OT - Gaming

All times are GMT +2. The time now is 06:13.

 -- EAB3 skin ---- EAB2 skin ---- Mobile skin Archive - Top