TGC Codebase Backup



Dark Distort by Richard Davey

12th Sep 2003 13:18
Summary

Trip back to the ST/Amiga days when distorting effects ruled! This simulates a classic distorter on a 320x240 bitmap. Use the cursor keys to change the step rate and speed of the d



Description

==========================================================
A Screaming Product Of The DARKFORGE (www.darkforge.co.uk)
==========================================================

Title

DarkDistort

Version

1.0

Date

March 25th 2000

Files

darkdistort.dba 1608 Bytes
zod4.bmp 230454 Bytes
darkdistort.gif 43543 Bytes

Programmer

Richard Davey
rich@fatal-design.com

DB Version

DarkBasic v1.02 (Registered)

License

Public Domain

Comments

Trip back to the ST/Amiga days when distorting effects
ruled! This simulates a classic distorter on a 320x240
bitmap. Use the cursor keys to change the step rate and
speed of the distort, you can produce some cool effects!
Increase the Z value on slower machines.

==========================================================
(c) www.darkforge.co.uk 2000
==========================================================



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    ` -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
`             DarkDistort v2
` -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
` By Rich Davey (rich@fatal-design.com)
` -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
` New version: Massive speed increase!
` Optimised code. Works with a bitmap
` of any size now (>16x16 pixels)
` Uses sprites not bobs :-)
`
` Music listened  to while  coding this
` Chicane - Behind the Sun CD
` -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

sync rate 0
sync on
hide mouse

`	You can replace this bitmap with any image > 16x16 in size

load bitmap "zod4.bmp",1

bw=bitmap width(1)
bh=bitmap height(1)

if bh<=16 or bw<=16
	print "BMP too small to distort properly"
	end
endif

`	Change the Z value for a smoother distortion effect
`	it must be a multiple of 2 (i.e. 2, 4, 6, 8, 16)

z=2 : y=0

`	Let's grab our sprites!

for i=1 to bh/z-1

	get image i,0,y,bw,y+z
	sprite i,-100,-100,i
	set sprite i,0,1
	inc y,z

next i

delete bitmap 1

`	Set-up the initial values

count=bh/z : step=1 : speed=4 : sx=0
offsetx=(screen width()-bw)/2
offsety=(screen height()-bh)/2

set current bitmap 0

do

	cls 0

	for a=1 to count
		sprite a,offsetx+cos(wrapvalue(sx+a*step))*100,offsety+(a*z),a
	next a

	inc sx,speed

	if upkey()
		inc speed
		if speed>64 then speed=64
	endif

	if downkey()
		dec speed
		if speed<0 then speed=0
	endif

	if leftkey()
		inc step
		if step>16 then step=16
	endif

	if rightkey()
		dec step
		if step<0 then step=0
	endif

	if spacekey() then end

	sync

loop