RocketEscape

Previous topic - Next topic

Kitty Hello

"Commander Zeek, geben sie auf, wir werden sie mit unserem Zy4000 nicht entkommen lassen". Strinrunzelnd brüllte Zeek in den Communicator: "Wenn sie ihn wiederhaben wollen, dann nur in Einzelteilen!".
"Angebot angenommen"
"..."
"FEUER FREI!".

Noch ehe sich der Commander am Kopf kratzen konnte flog schon die erste Zielsuchrakete an ihm vorbei.
Du bist Zeek - wie lange kannst Du entfliehen?

Code (glbasic) Select
// --------------------------------- //
// Project: RocketEscape
// Start: Sunday, February 05, 2006
// IDE Version: 3.032

STARTPOLY -1
POLYVECTOR 31,16,0,0,RGB(255,255,255)
POLYVECTOR 1,1,0,0,RGB(0,255,0)
POLYVECTOR 4,12,0,0,RGB(0,0,255)
POLYVECTOR 4,20,0,0,RGB(0,0,255)
POLYVECTOR 1,31,0,0,RGB(0,255,0)
ENDPOLY

GRABSPRITE 0,0,0,32,32

FILLRECT 0,0,64,64,RGB(255,0,128)
STARTPOLY -1
POLYVECTOR 1,24,0,0,RGB(255,255,0)
POLYVECTOR 31,16,0,0,RGB(255,0,0)
POLYVECTOR 1,8,0,0,RGB(255,255,0)
ENDPOLY
GRABSPRITE 1,0,0,32,32
// fixing transparency on some gfx-cards
SAVESPRITE 1, "tmp.bmp"
LOADSPRITE "tmp.bmp", 1
BLACKSCREEN


DIM ppos[2]
DIM rpos[4][2]
DIM rdir[4]
DIM poof[0][2]
NewRocket(0)
NewRocket(1)
NewRocket(2)
NewRocket(3)

pspeed = 1.2


AddPoof(0,0)

WHILE TRUE
mx = MOUSEAXIS(0)/10
pdir = pdir-mx
ppos[0]=ppos[0]+COS(pdir)*pspeed
ppos[1]=ppos[1]-SIN(pdir)*pspeed

offx = 320-ppos[0]
offy = 240-ppos[1]

FOR i=0 TO BOUNDS(rpos[], 0)-1
score=score+1

// get rocket new direction
phi = -ATAN(ppos[1]-rpos[i][1], ppos[0]-rpos[i][0])

WHILE phi>rdir[i]+180; phi=phi-360; WEND
WHILE phi
IF phi rdir[i] = rdir[i]-1
ELSE
rdir[i] = rdir[i]+1
ENDIF

// move rocket
rpos[i][0] = rpos[i][0] + COS(rdir[i])
rpos[i][1] = rpos[i][1] - SIN(rdir[i])

// draw rockets
ROTOSPRITE 1, rpos[i][0]+offx, rpos[i][1]+offy, rdir[i]

// collision: rocket-rocket
FOR j=i+1 TO BOUNDS(rpos[], 0)-1
dx = rpos[i][0]-rpos[j][0]
dy = rpos[i][1]-rpos[j][1]
dist = SQR(dx*dx+dy*dy)
IF dist<24
AddPoof(rpos[i][0], rpos[i][1])
score=score+1000
NewRocket(i)
NewRocket(j)
j = BOUNDS(rpos[],0)
REDIM rpos[j+1][2]
REDIM rdir[j+1][2]
NewRocket(j)
BREAK
ENDIF
NEXT

// collision: rocket-player
dx = rpos[i][0]-ppos[0]
dy = rpos[i][1]-ppos[1]
dist = SQR(dx*dx+dy*dy)
IF dist<24
GameOver()
BREAK
ENDIF
NEXT


// draw player
ALPHAMODE .2
ROTOZOOMSPRITE 1, ppos[0]+offx-64*COS(pdir), ppos[1]+offy+64*SIN(pdir), pdir, 2+SIN(GETTIMERALL()/2)/4
ALPHAMODE 0
ROTOSPRITE 0, ppos[0]+offx, ppos[1]+offy, pdir

DrawPoof(offx, offy)


// radar
VIEWPORT 0,10,100,100
ALPHAMODE -.5
DRAWLINE 0,50,100,50,RGB(255,255,255)
DRAWLINE 50,0,50,100,RGB(255,255,255)
FOR i=0 TO BOUNDS(rpos[], 0)-1
ROTOZOOMSPRITE 1, (rpos[i][0]-ppos[0])/30+50-16, (rpos[i][1]-ppos[1])/30+50-16, rdir[i], .3
NEXT
ALPHAMODE -.2
FILLRECT 0,0,100,100,RGB(255,255,255)
VIEWPORT 0,0,0,0

PRINT "Score: " + score,0, 0
SHOWSCREEN
WEND

FUNCTION AddPoof: x, y
LOCAL n
n = BOUNDS(poof[], 0)
REDIM poof[n+1][3]
poof[n][0]=x
poof[n][1]=y
poof[n][2]=GETTIMERALL()
ENDFUNCTION

FUNCTION DrawPoof: offx, offy
LOCAL i, j, f, t, n
n = BOUNDS(poof[], 0)-1
t=GETTIMERALL()
FOR i=0 TO n
f = (t - poof[i][2])/1000
IF f>1
poof[i][0]=poof[n][0]
poof[i][1]=poof[n][1]
poof[i][2]=poof[n][2]
REDIM poof[n][3]
t=t-1
n=n-1
CONTINUE
ENDIF
ALPHAMODE f-1
FOR j=0 TO 15
x = poof[i][0]+COS(j*360/16)*f*100*(1+MOD(j,2))
y = poof[i][1]-SIN(j*360/16)*f*100*(1+MOD(j,2))
ROTOZOOMSPRITE 1, x+offx, y+offy, f*720+j*360/16, 1+f
NEXT
NEXT
ALPHAMODE 0
ENDFUNCTION


FUNCTION NewRocket: i
rdir[i] = RND(360)
rpos[i][0] = ppos[0]+500*COS(rdir[i])
rpos[i][1] = ppos[1]+500*SIN(rdir[i])
ENDFUNCTION

FUNCTION GameOver:
PRINT "GAME OVER", 100, 100
PRINT "Score: "+score, 0,0
SHOWSCREEN
MOUSEWAIT

REDIM rpos[2][2]
REDIM rdir[2]
NewRocket(i)
NewRocket(j)
score=0

ENDFUNCTION
"174 Befehle. Over"

BumbleBee

Logbuch Eintrag.
Zeek wurde vernichtet. Es gab keine Überlebenden.
Nehme jetzt Kurs Richtung Stern Beta GLBasic 3.032
Sternzeit 13.7

Ausgezeichnete Arbeit Captain.

Over
The day will come...

CPU Intel(R) Core(TM) i5-3570k, 3.4GHz, AMD Radeon 7800 , 8 GB RAM, Windows 10 Home 64Bit

WPShadow

Super Spiel!

592873

Ab 250000 wird es kaum noch spielbar!!!
AMD X2 4600, 2 GB Ram, ATI X1950 XTX, XP PRO SP2: GLB Premium 10.beta_dingsi, <(´.´<) Kirby Dance (>`.`)>
http://lostrevenant.blogspot.com
alea iacta est