Turbojelly Kommando edition
Posted: Mon Nov 07, 2011 9:46 am
Game Making Should Be Easy...
https://www.coolbasic.com/phpBB3/
Code: Select all
//TURBO JELLY 3000 - a Peisik (CCE&msqrt) game for Revision 2011!
//---Some mechanics modded---
SetWindow "TURBO JELLY 3000"
SCREEN 640, 480
fonta=LoadFont("arial",24)
SetFont fonta
a=-1
Repeat
CenterText 320,240,"Fullscreen: Y/N?",2
If KeyHit(49) Then a=1
If KeyHit(21) Then a=0
DrawScreen
Until a>-1
Cls
SCREEN 640, 480,0,a
FrameLimit 60
fonta=LoadFont("arial",24)
DefaultMask ON, 255, 0, 255
enemyimg = LoadImage("data/enemy.png")
imgr = LoadImage("data/player.png")
bomb = LoadImage("data/bomb.png")
bombs= LoadImage("data/bomb_shadow.png")
expl = LoadImage("data/pampam.png")
pshadow = LoadImage("data/shadow.png")
bg1 = LoadImage("data/bg01.png")
bg2 = LoadImage("data/bg02.png")
bg3 = LoadImage("data/bg03.png")
peisiklogo = LoadImage("data/biglogo.png")
gamelogo = LoadImage("data/newlogo.png")
info = LoadImage("data/infotext.png")
prstrt = LoadImage("data/press_start.png")
puffi = LoadImage("data/puff.png")
crate=LoadImage("data/crate.png")
boom = LoadSound("data/boom.ogg")
throw = LoadSound("data/throw.ogg")
start = LoadSound("data/start.ogg")
hit = LoadSound("data/hit.ogg")
pickup = LoadSound("data/pickup.ogg")
open = LoadSound("data/opening.ogg")
imgl = CloneImage(imgr)
For i = 0 To ImageWidth(imgr)/64
For j = 0 To 63
CopyBox 64*(i+1)-j,0,1,64,64*i+j,0,Image(imgr), Image(imgl)
Next j
Next i
img=imgr
Dim percent(4) As Float
Dim colbase(4,1) As Float
Type enemy
Field x#
Field y#
Field xv#
Field yv#
Field health
Field col
Field framet
Field followt
EndType
Type puff
Field x
Field y
Field t
EndType
Type shot
Field x#
Field y#
Field h#
Field xv#
Field hv#
Field stimer
Field dtimer
EndType
fontc=LoadFont("arial",12)
SetFont fonta
introt = Timer()
Repeat
If Timer()-introt>500 And Timer()-introt<2500 Then DrawImage peisiklogo,-20,160
If KeyHit(28) Or KeyHit(57) Then Exit
DrawScreen
Until introt+3000<Timer()
Repeat
PlaySound open
px#=320
py#=340
ClsColor 85,122,133
starttime = Timer()+480
Repeat
DrawImage bg1,-(px-40)/460.0*10.0,300
DrawImage bg2,-(px-40)/460.0*5.0,300-31
DrawImage bg3,0,300
DrawImage gamelogo, 20, 20+4*Sin(Timer()/10.0)
DrawImage info, 0, 250
If (Timer() Mod 1000 > 500) Then DrawImage prstrt, 180, 400
Color 0,0,0
Box 0,0,640,(starttime-Timer())/2.0
Box 0,480-(starttime-Timer())/2.0, 640, (starttime-Timer())/2.0
DrawScreen
Until (KeyHit(28) Or KeyHit(57))
PlaySound start
tttimer = Timer()
Repeat
yc# = (Timer()-tttimer)/1000.0
yc = 300+300*yc*yc*(2*yc-3)
DrawImage bg1,-(px-40)/460.0*10.0,yc
DrawImage bg2,-(px-40)/460.0*5.0,yc-31
DrawImage bg3,0,yc
DrawScreen
Until tttimer+1000<Timer()
px#=320
py#=340
shottimer = 0
dir = 1
rtimer = Timer()
stimer = Timer()+2000
pframe = 0
pxv# = .0
pyv#=.0
cratet = Timer()+Rand(10000,20000)
crateis = 0
health = 100
spawninterval = 1000
killindicatorsize#=.1
dtimer = -1
For i = 0 To 4
colbase(i,0)=Rnd(40,600)
colbase(i,1)=Rnd(200,440)
Next i
kills=0
Repeat
If (Not SoundPlaying(music)) And health>0 Then music=PlaySound("data/track.ogg")
DrawImage bg1,-(px-40)/460.0*10.0,0
DrawImage bg2,-(px-40)/460.0*5.0,-31
DrawImage bg3,0,0
If health>0 Then DrawImage pshadow, px-31, py+4
If crateis Then DrawImage pshadow, cratex-30, cratey-8
For s.shot = Each shot
If s\stimer>Timer() And s\stimer-1400<Timer() then DrawImage bombs, s\x-4,s\y+3
Next s
For e.enemy=Each enemy
DrawImage pshadow, e\x-29, e\y+1
Next e
If cratet<Timer()
cratet = Timer()+Rand(10000,15000)
crateis = 1
cratex = Rand(40,600)
cratey = Rand(220,460)
crateh# = 450
cratehv# = .0
EndIf
If pshottimer = 0
If health>0 Then
px = Min(600,Max(40,px+1.5*(RightKey()-LeftKey())))
mv=0
If RightKey() Then dir=1:mv=1
If LeftKey() And RightKey()=0 Then dir=-1:mv=1
If mv=0 And DownKey()=0 And UpKey()=0 Then anim=0 Else anim = 1
py = Min(460,Max(220,py+1.5*(DownKey()-UpKey())))
px = px + pxv#
py = py + pyv#
pxv = pxv*.9
pyv = pyv*.9
EndIf
If rtimer>Timer()+400 Then anim=2
EndIf
If stimer<Timer()
stimer=Timer()+spawninterval
spawninterval = max(400,spawninterval-2)
e.enemy=New(enemy)
If Rand(1) Then
If rand(1) then e\x=-40 Else e\x=680
e\y=Rnd(200,440)
Else
e\x=Rnd(40,600)
e\y=520
EndIf
e\col = Rand(0,4)
e\framet = Rand(599)
e\followt=Timer()+6000
EndIf
//Välilyönti
If KeyDown(57) Then
//Pommin kädessäpitoanimaatio
If rtimer<Timer() Then anim=3
//Jos pidät pommia liian pitkään kädessä, se posahtaa naamallesi
If pshottimer<Timer() And pshottimer Then
rtimer = Timer()+3200
s.shot=New(shot)
s\x=px
s\y=py
s\stimer=0
PlaySound throw,30
pshottimer = 0
EndIf
//Jos pommi ei ole kädessä, niin asetetaan pommin ajastin
If rtimer<Timer() And pshottimer<1 Then
pshottimer = Timer() + 1400
EndIf
EndIf
//Kun välilyönti päästetään
If rtimer<Timer() And pshottimer>Timer() And KeyUp(57) And health>0 Then
rtimer = Timer()+1200
s.shot=New(shot)
s\x=px+20*dir
s\y=py
s\h=30
s\xv=dir*6
s\hv=4.0
s\stimer=Timer()+(pshottimer-Timer())
PlaySound throw,30
pshottimer = 0
EndIf
For e.enemy=Each enemy
If colbase(e\col,0)>=0 And Distance(px,py,e\x,e\y)>128 Then
ex#=colbase(e\col,0)-e\x
ey#=colbase(e\col,1)-e\y
Else
ex#=px-e\x
ey#=py-e\y
EndIf
If Distance(px,py,e\x,e\y)<32 And health>0 Then
dx# = px-e\x
dy# = py-e\y
pxv = dx*.2
pyv = dy*.2
e\xv = -dx*.2
e\yv = -dy*.2
health = health - Rand(8,12)
PlaySound hit
dmgtaken=1
EndIf
l# = (.1+.9*Sin((Timer()-e\framet)/6.0)^2)/Sqrt(ex*ex+ey*ey)
ex = ex*l
ey = ey*l
e\x = e\x + ex
e\y = e\y + ey
If e\x+e\xv<600 and e\x+e\xv>40 Then e\x = e\x + e\xv
if e\y+e\yv<460 And e\y+e\yv>220 Then e\y = e\y + e\yv
e\xv = e\xv*.9
e\yv = e\yv*.9
If Distance(e\x,e\y,colbase(e\col,0),colbase(e\col,1))<10 Or e\followt<Timer() Then
colbase(e\col,0)=Rnd(40,600)
colbase(e\col,1)=Rnd(200,440)
If Rand(3)=0 Then
colbase(e\col,0)=-1
colbase(e\col,1)=-1
EndIf
For k.enemy=Each enemy
If e\col=k\col Then k\followt=Timer()+6000
Next k
EndIf
DrawImageBox enemyimg,e\x-32,e\y-48,64*(RoundDown((Timer()-e\framet)/200.0) Mod 4),64*e\col,64,64
Next e
For s.shot = Each shot
If s\stimer>Timer() Then
If s\stimer-1400<Timer()
s\x=s\x+s\xv
s\h=s\h+s\hv
If s\h<.0 Then s\h=Abs(s\h)/2.0:s\hv=s\hv*-.6:s\xv=s\xv*.75
s\xv=s\xv*.99
s\hv=s\hv-.6
DrawImage bomb, s\x-4, s\y-s\h-6
EndIf
Else
If s\dtimer=0 Then
For e.enemy=Each enemy
If BoxOverlap(s\x-64,s\y-32,128,64,e\x-32,e\y-16,64,32) Then
p.puff = New(puff)
p\x=e\x
p\y=e\y
p\t=Timer()
Delete e
kills=kills+1
killindicatorsize=killindicatorsize+.1
percent(e\col)=percent(e\col)+1
EndIf
e\xv = e\xv+250*(e\x-s\x)/Max(.1,Distance(e\x,e\y,s\x,s\y)^2)
e\yv = e\yv+250*(e\y-s\y)/Max(.1,Distance(e\x,e\y,s\x,s\y)^2)
Next e
//Pelaajan elämänmenetys
health = health - RoundDown(Max(0, (200-Distance(px, py, s\x, py+(s\y-py)/2))/200)*30)
//Pelaajan sinkoutuminen
pxv = pxv + 250*(px-s\x)/Max(0.1,Distance(px, py, s\x, s\y)^2)
pyv = pyv + 250*(py-s\y)/Max(0.1,Distance(px, py, s\x, s\y)^2)
s\dtimer = Timer()
PlaySound boom
EndIf
EndIf
If s\dtimer<>0 Then
If s\dtimer>Timer()-700 Then
DrawImageBox expl, s\x-48, s\y-78, 96*(7-RoundDown(Abs(Timer()-700-s\dtimer)/100.0)),0,96,96
Else
Delete s
EndIf
EndIf
Next s
For p.puff=Each puff
DrawImageBox puffi, p\x-48, p\y-96, 96*RoundDown((Timer()-p\t)/100.0),0,96,96
If p\t+400<Timer() Then Delete p
Next p
dmgtaken=0
Select anim
Case 0
pframe = RoundDown(Timer()/500.0) Mod 2
Case 1
pframe = RoundDown(Timer()/150.0) Mod 4
Case 2
pframe = Min(6, 11+RoundDown((Timer()-rtimer)/200.0))
Case 3
pframe = 5
EndSelect
If dir>0 Then img=imgr Else img=imgl
If health>0 Then
DrawImageBox img,px-32,py-48,64*pframe,0,64,64
Else
If dtimer<0 Then dtimer=Timer()//:PlaySound boom
StopSound music
If Timer()<dtimer+700 then DrawImageBox expl, px-48, py-78, 96*(7-RoundDown(Abs(Timer()-700-dtimer)/100.0)),0,96,96
If Timer()>dtimer+1700 Then Exit
EndIf
If crateis
crateh = crateh + cratehv
cratehv=cratehv-.3
If crateh<.0 Then crateh=Abs(crateh)/2.0:cratehv=cratehv*-.1
If crateh<40.0 And Distance(px,py,cratex,cratey)<40 Then health = Min(100,health + Rand(10,30)):crateis=0:PlaySound pickup
DrawImageBox crate,cratex-24,cratey-crateh-43,((Timer() Mod 500)>450)*48,0,48,48
cratet = Timer()+Rand(10000,15000)
EndIf
Color 255,255*(killindicatorsize<.9),255*(killindicatorsize<.9)
killindicatorsize = min(1.0,Max(.6,killindicatorsize*.99))
fontb = LoadFont("Arial",killindicatorsize*60)
SetFont fontb
CenterText 40,70,kills+" KILLS",1
SetFont fonta
DeleteFont fontb
Color 0,0,0
Box 40, 30, 560, 20
Color 255,255*dmgtaken,255*dmgtaken
Box 45, 35, health/100.0*550.0,10
DrawScreen
Forever
ClsColor 0,0,0
For s.shot = Each shot
Delete s
Next s
For e.enemy=Each enemy
Delete e
Next e
endtime=Timer()+8000
For i = 0 To 4
percent(i) = Int(percent(i)/Float(kills)*10000)/100.0
Next i
Repeat
Color 255,0,0
SetFont fonta
Text 320-(w1+w2+w3)/2.0+w1,h, Str(kills)+" KILLS"
Color 255,255,255
CenterText 320,140,"GAME OVER, FUCKER",2
w1 = TextWidth("YOU GOT ")
w2 = TextWidth(Str(kills)+" KILLS")
w3 = TextWidth(" BUT FAILED T"+"O SURVIVE")
h = 200-TextHeight("YOU GOT "+Str(kills)+" KILLS BUT FAILED T"+"O SURVIVE")/2
Text 320-(w1+w2+w3)/2.0, h,"YOU GOT"
Text 320-(w1+w2+w3)/2.0+w1+w2,h," BUT FAILED T"+"O SURVIVE"
CenterText 320,260,"PRESS SPACE/ENTER T"+"O PLAY AGAIN, ESC T"+"O QUIT",2
SetFont fontc
For i = 0 To 4
DrawImageBox enemyimg,Max(0,(endtime-Timer())/10.0)+128+80*i,340+20*Sin(Timer()/6.0+i*72),64*(RoundDown((Timer()-i*200)/400.0) Mod 4),64*i,64,64
If kills>0 Then CenterText Max(0,(endtime-Timer())/10.0)+160+80*i,400+20*Sin(Timer()/6.0+i*72),Str(percent(i))+"%"
Next i
DrawScreen
Until KeyHit(57) or KeyHit(28)
Cls
Wait 5
DrawScreen
Forever
Jooh, en nyt mitään ihmeellisempää jaksanut yhden hypärin aikana viritellä. Läpällä tein tämänkin.elmo123 wrote:Modin grafiikat eivät minun silmääni oikein kolahtaneet. Grafiikan jääminen ainoaksi modin modaavaksi piirteeksi ei myöskään täytä omia kriteerejäni modiksi luokitteluun.