Graphics Demo: Camera Shake

by (Login KristopherWindsor)

I really enjoy making graphics such as particle effects and rain because I can put them together and get a nice looking game, which is why I would look to use as many graphics features as I can.

I made this program to demonstrate my latest: a camera shake. Just watch it and don't ask why the safe is falling in the middle of a forest. {:-D)


'\ITECH\DEMO\CAMSHAKE\CAMSHAKE
' Camera Shake Demo! Version 1.0
' (C) 2006 i-TECH and Kristopher Windsor

DECLARE SUB shake ()
CONST bcolor = 9, boxs = 40, tcount = 25
COMMON SHARED shaked, shakex, shakey, pshaked, pshakex, pshakey
TYPE tree: x AS INTEGER: y AS INTEGER: green AS INTEGER: height AS INTEGER: leafdist AS INTEGER: leafsize AS INTEGER: END TYPE
DIM t(1 TO tcount) AS tree, k AS STRING, boxv AS SINGLE, boxx AS INTEGER, boxy AS INTEGER
DIM a AS INTEGER, b AS INTEGER, framecount AS INTEGER

SCREEN 12: RANDOMIZE TIMER: LINE (0, 0)-(639, 479), bcolor, BF: boxx = 560

FOR a = 1 TO tcount
t(a).x = INT(RND * 500) + 10: t(a).y = INT(RND * 200) + 200
t(a).green = INT(RND * 90) + 10: t(a).height = t(a).green * 2
t(a).leafdist = INT(RND * 10) + 10: t(a).leafsize = INT(RND * 20) + 10
NEXT a

DO
IF k = " " THEN shaked = shaked * 1.2 + 10

FOR a = 1 TO tcount
LINE (t(a).x + pshakex, t(a).y + pshakey)-(t(a).x + pshakex, t(a).y + t(a).height + pshakey), bcolor
LINE (t(a).x + shakex, t(a).y + shakey)-(t(a).x + shakex, t(a).y + t(a).height + shakey), 6
FOR b = t(a).y TO t(a).y + t(a).green STEP t(a).leafdist
LINE (t(a).x + pshakex, b + pshakey)-(t(a).x - t(a).leafsize + pshakex, b + t(a).leafdist + pshakey), bcolor
LINE (t(a).x + shakex, b + shakey)-(t(a).x - t(a).leafsize + shakex, b + t(a).leafdist + shakey), 10
LINE (t(a).x + pshakex, b + pshakey)-(t(a).x + t(a).leafsize + pshakex, b + t(a).leafdist + pshakey), bcolor
LINE (t(a).x + shakex, b + shakey)-(t(a).x + t(a).leafsize + shakex, b + t(a).leafdist + shakey), 10
NEXT b
NEXT a

LINE (boxx, boxy)-(boxx + boxs, boxy + boxs), bcolor, BF
IF boxy + boxs > 478 THEN shaked = shaked + INT(RND * 60): boxy = -boxs: boxv = 0 ELSE boxv = boxv + .2: boxy = boxy + boxv
LINE (boxx, boxy)-(boxx + boxs, boxy + boxs), 8, BF

CALL shake
k = INKEY$: IF k = CHR$(13) THEN LOCATE 1, 1: PRINT framecount: SLEEP
framecount = framecount + 1
LOOP UNTIL k = CHR$(27)
SYSTEM

SUB shake
CONST ss = 2
STATIC ccount: ccount = ccount + 1
IF shaked = 0 THEN EXIT SUB ELSE shaked = shaked / 1.2
pshaked = shaked: pshakex = shakex: pshakey = shakey
shakex = COS(ccount * ss) * shaked: shakey = SIN(ccount * ss) * shaked
END SUB



There are -(NOT(0))*2 kinds of people in this world, those who know true from false and those who don't.

Kristopher Windsor, the Dnttch-Tzmne
Author of iOS | geocities.com/tzmne

Posted on Jul 17, 2006, 8:36 AM

Respond to this message   

Goto Forum Home


Response TitleAuthor and Date
*Neat! (of course it could be a boulder from an avalanche, -some are cubic). on Jul 17