TGC Codebase Backup



It's a sin! by Richard Davey

29th Sep 2003 14:06
Summary

This is a traditional sine-wave routine, only it pre-calculates the sine and cosine waves so we only paste 1 image every frame, not every line. This means we can get x21 256x113 di



Description



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    `	-------------------------------------------------------------------------
`	It's a sin                                            DarkForge 16/2/2001
`	-------------------------------------------------------------------------
`	This is a traditional sine-wave routine, only it pre-calculates the sine
`	and cosine waves so we only paste 1 image every frame, not every line.
`	This means we can get x21 256x113 distorters going at full frame rate!

sync rate 0
sync on
hide mouse

load bitmap "dflogo.bmp",1

sih = bitmap height(1)
siw = bitmap width(1)

for i=1 to sih
	get image i,0,i-1,siw,i
next i

create bitmap 2,640,480

r = 0 : e = 120 : step = 3 : sx = 0 : speed = 3

repeat

	cls

`	pre-calc the sine wave pattern
	for i=1 to sih
		s# = 30+sin(sx+i*step)*25
		paste image i,s#,i
	next i
	get image 1000+r,0,0,325,sih

`	pre-calc the cosine wave pattern
	for i=1 to sih
		s# = 30+cos(sx+i*step)*25
		paste image i,s#,sih+i
	next i
	get image 1500+r,0,sih,325,sih+sih

	inc sx,speed : inc r

until r=e

r=0
create bitmap 3,640,480

do

	cls

	for a=0 to 480-sih step sih*2
		paste image 1000+r,0,a,1
		paste image 1500+r,0,a+sih,1
		paste image 1500+r,300,a+sih,1
		paste image 1000+r,300,a,1
	next a

	inc r : if r=e then r=0

`	Un-comment for FPS
`	text 0,0,str$(screen fps())

	copy bitmap 3,0
	sync

loop