Lisäksi, peli ei tarvitse toimiakseen muuta kuin .exen, mutta kahdella .xm-filulla saa peliin musiikit ja niihin perustuvia efektejä. Peli siis tekee grafiikat koodissa, vaikka ajon aikana tallentaakin pelihahmon kuvan kansioon, jotta sen voi ladata animoituna.
Ennen kaikkea, haluan kommentteja/ideoita jne. jne. Koodi ja paketti (paketissa mukana myös koodi):
Code: Select all
Const XST=5
Const YST=5
w=250
h=150
SCREEN w*2,h*2,0,1
SCREEN w,h,0,2
Const VALI=20
Type SEL
Field x
Field y
Field c
Field id
Field txt As String
EndType
Type PAL
Field x As Float
Field y As Float
Field kx As Float
Field ky As Float
Field s
Field is
EndType
sss=h/20
pa.PAL=New(PAL)
pa\x=0
pa\y=h/2
pa\s=sss
ukko=MakeImage(6,4)
mouse=MakeImage(6,6)
start=Timer()
font=LoadFont("courier new",12)
SetFont font
logo=MakeImage(TextWidth("The Jump"),TextHeight("The Jump"))
logo2=MakeImage(TextWidth("The Jump"),TextHeight("The Jump"))
teks=TextHeight("")-4
d=3
DrawToImage ukko
//1. Frame
Dot 0,1
Dot 1,1
Dot 2,1
Dot 1,2
Dot 0,3
Dot 2,3
//2. Frame
Dot 3,1
Dot 4,1
Dot 5,1
Dot 4,2
Dot 4,3
DrawToImage mouse
Color 1,1,1
For i=0 To 6
Line 0,0,6-i,6
Next i
Color 255,170,0
Line 0,0,6,6
Line 0,0,0,6
Line 0,5,5,5
DrawToImage logo
Color 42*1.2,42*1.5,42*1.8
Text 0,0,"The Jump"
DrawToImage logo2
Color 127,127*1.5,127*2
Text 0,0,"The Jump"
DrawToScreen
ResizeImage logo,TextWidth("The Jump")*3,TextHeight("The Jump")*3
ResizeImage logo2,TextWidth("The Jump")*3,TextHeight("The Jump")*3
RotateImage mouse,90
Type BOXIT
Field x As Float
Field spe As Float
Field le
Field id
EndType
Type TBOX
Field x As Float
Field spe As Float
Field y As Float
Field m
EndType
Type STAR
Field x As Float
Field y As Float
Field yy As Float
Field is2
Field spe As Float
Field jako As Float
EndType
SaveImage ukko,"ukko.png"
ukko1=LoadAnimImage("ukko.png",3,4,0,2)
f=OpenToEdit("score.txt")
rpist=ReadInt(f)
rmatk=ReadInt(f)
rboos=ReadInt(f)
rtahd=ReadInt(f)
CloseFile f
SAFEEXIT OFF
ShowMouse OFF
ms=1
mx=MouseX()
my=MouseY()
vy=ImageHeight(logo)+3
music=1
debug=0
tausta=1
bpm=130
askel=100
Locate 0,vy
For i=1 To 5
se.SEL=New(SEL)
se\x=w/2
se\y=vy+i*(teks+6)
se\c=255
se\id=i
Select i
Case 1
se\txt="Start"
Case 2
se\txt="Options"
Case 3
se\txt="About & Help"
Case 4
se\txt="Credits"
Case 5
se\txt="Quit"
EndSelect
Next i
menu:
If SoundPlaying(mus) Then
StopSound mus
EndIf
If FileExists("menumusic.xm") And music=1 Then
mus=PlaySound("menumusic.xm",20)
EndIf
Repeat
If FileExists("menumusic.xm") And SoundPlaying(mus)=0 And music=1 Then
mus=PlaySound("menumusic.xm",20)
EndIf
If debug=0 Then
ClearText
EndIf
DrawImage logo,w/2-ImageWidth(logo)/2,2
DrawImage logo2,w/2-ImageWidth(logo2)/2-3,-1
For se.SEL=Each SEL
If se\id<6 Then
se\c=127-Min(85,Distance(se\x/(w/40),se\y,mx/(w/40),my)*4)
Color 0.2*se\c,0.2*se\c*1.5,0.2*se\c*2
Box se\x-2-TextWidth(se\txt)/2,se\y-d*2,TextWidth(se\txt)+4,TextHeight(se\txt),1
Color se\c,se\c*1.5,se\c*2
Box se\x-2-TextWidth(se\txt)/2,se\y-d*2,TextWidth(se\txt)+4,TextHeight(se\txt),0
CenterText se\x,se\y,se\txt,2
If Distance(0,se\y,0,my)<8 Then
If MouseHit(1) Or KeyHit(28) Then
If debug=1 Then
AddText se\txt
EndIf
Select se\id
Case 1
Goto game
Case 2
Goto optio
Case 3
Goto about
Case 4
Goto credits
Case 5
Goto loppu
EndSelect
EndIf
EndIf
EndIf
Next se
mx=MouseX()
my=MouseY()
Color 120,120,120
Line 0,vy,w,vy
DrawImage mouse,MouseX(),MouseY()
DrawScreen
Until KeyHit(1)
Goto loppu
game:
cc#=0
x=50
y#=h-30
x2#=51
y2#=h-33
yvel#=0
spe#=4
sped#=4
b.BOXIT=New(BOXIT)
b\x=0
b\spe=spe
b\le=w
b\id=boxis+1
boxis+1
If tausta=1 Then
bo.TBOX=New(TBOX)
bo\x=w
bo\spe=sped/2
bo\y=120
bo\m=1
bo.TBOX=New(TBOX)
bo\x=w
bo\spe=sped/1.5
bo\y=140
bo\m=2
EndIf
boxialla=1
pisteet=0
matka=0
h2=10
xx#=0
rn1#=1
rn2#=1.5
rn3#=2
yy#=h/3
rn11#=CurveValue(rn1,rn11,20)
rn22#=CurveValue(rn2,rn22,20)
rn33#=CurveValue(rn3,rn33,20)
If SoundPlaying(mus) Then
StopSound mus
EndIf
If FileExists("ingame.xm") And music=1 Then
mus=PlaySound("ingame.xm",20)
EndIf
rrt=2
Repeat
If FileExists("ingame.xm") And SoundPlaying(mus)=0 And music=1 Then
mus=PlaySound("ingame.xm",20)
EndIf
If FileExists("ingame.xm") And music=1 Then
aika=Timer()-start
väli=60000/bpm
tahdit=aika/(väli*4)+1
pattern=aika/(väli*16)+1
iskut=aika/väli+1
If iskut>is Then
rr#=rrt
is=iskut
EndIf
If tahdit>4 Then
rrt=5
EndIf
rr=rr-0.2
rr=Max(0,rr)
Else
rr=0.5
EndIf
xx+0.1
If xx>w+30 Then xx=-30
If matka>m+2000 Then
rn1=Rnd(1,2)
rn2=Rnd(1,2)
rn3=Rnd(1,2)
m=matka
x=x+1
sped=sped+0.5
EndIf
If y>h-29 Then
rn11#=CurveValue(0,rn11,20)
rn22#=CurveValue(0,rn22,20)
rn33#=CurveValue(0,rn33,20)
te=0
Else
rn11#=CurveValue(rn1,rn11,20)
rn22#=CurveValue(rn2,rn22,20)
rn33#=CurveValue(rn3,rn33,20)
EndIf
If tausta=1 Then
Gosub meta
Else
For i=0 To 120
Color Min(255,i*(rn11+rr/10)),Min(255,i*(rn22+rr/10)),Min(255,i*(rn33+rr/10))
Line 0,h-30-i,w,h-30-i
Next i
EndIf
Color 60*rn11,60*rn22,60*rn33
Line 0,h-29,w,h-29
For p.TBOX=Each TBOX
cc=0
If p\m<2 Then
For yyy=p\y To h
cc+1
Color Max(0,(40+p\spe)-cc)*rn11,Max(0,(40+p\spe)-cc)*rn22,Max(0,(40+p\spe)-cc)*rn33
Line p\x,yyy,p\x+VALI+sped,yyy
Next yyy
EndIf
p\x-p\spe
If p\m=1 And p\x<w-VALI And tausta=1 Then
bo.TBOX=New(TBOX)
bo\x=w
bo\spe=spe/2
bo\y=p\y+Rnd(-3,3)
If bo\y>h-20 Then bo\y=p\y+Rand(-1,0)*10
If bo\y<h-40 Then bo\y=p\y+Rand(0,1)*10
bo\m=1
p\m=0
EndIf
If p\m=2 And p\x<w-VALI And tausta=1 Then
bo.TBOX=New(TBOX)
bo\x=w
bo\spe=spe/1.5
bo\y=p\y+Rnd(-3,3)
If bo\y>h Then bo\y=p\y+Rand(-1,0)*10
If bo\y<h-20 Then bo\y=p\y+Rand(0,1)*10
bo\m=2
p\m=3
EndIf
If p\x<-VALI Then Delete p
Next p
For p2.TBOX=Each TBOX
cc=0
If p2\m>1 Then
For yyy=p2\y To h
cc+1
Color Max(0,(80+p2\spe*2)-cc)*rn11,Max(0,(80+p2\spe*2)-cc)*rn22,Max(0,(80+p2\spe*2)-cc)*rn33
Line p2\x,yyy,p2\x+VALI+sped,yyy
Next yyy
EndIf
Next p2
For s.STAR=Each STAR
If s\spe<=sped Then
Color Min(255,120*(rn11+rr/10)),Min(255,120*(rn22+rr/10)),Min(255,120*(rn33+rr/10))
Box s\x,s\y,1,1,1
s\x=s\x-s\spe
s\y=CurveValue(s\yy,s\y,10)
If iskut>s\is2 Then
s\y=s\y+Rnd(-4,0)
s\is2=iskut
EndIf
s\spe=spe/s\jako
If s\x<0 Then Delete s
If BoxOverlap(x,y-3,6,4,s\x,s\y,1,1) Then
Delete s
napattu+1
EndIf
EndIf
Next s
For b.BOXIT=Each BOXIT
Color 80*rn11,80*rn22,80*rn33
Box b\x,h-29,b\le,h2
If y<h-29 Then
Color 255,170,0
Else
Color 120*rn11,60*rn22,1*rn33
EndIf
Line b\x,h-29,b\x+b\le-1,h-29
Line b\x,h-29+h2,b\x+b\le-1,h-29+h2
Line b\x,h-29,b\x,h-29+h2
Line b\x+b\le,h-29,b\x+b\le,h-29+h2
b\x-b\spe
b\spe=spe
If b\x+b\le<w And boxis<2 Then
b2.BOXIT=New(BOXIT)
b2\x=w+100
b2\spe=spe
b2\le=Rand(10,60)*10
b2\id=boxis+1
boxis+1
EndIf
If b\x+b\le<0 Then
Delete b
boxis-1
If y<h-30 Then
pisteet+1
EndIf
EndIf
Next b
Lock
pix=GetPixel2(x,y+1)
Unlock
For s.STAR=Each STAR
If s\spe>sped Then
Color Min(255,120*(rn11+rr/10)),Min(255,120*(rn22+rr/10)),Min(255,120*(rn33+rr/10))
Box s\x,s\y,1,1,1
s\x=s\x-s\spe
s\y=CurveValue(s\yy,s\y,20)
If iskut>s\is2 Then
s\y=s\y+Rnd(-4,0)
s\is2=iskut
EndIf
s\spe=spe/s\jako
If s\x<0 Then Delete s
If BoxOverlap(x,y-3,6,4,s\x,s\y,1,1) Then
Delete s
napattu+1
EndIf
EndIf
Next s
If y=h-30 Then
hypyt=0
If pix=-22016 Then
boxialla=1
Else
boxialla=0
EndIf
EndIf
yvel=yvel-0.092
If KeyHit(57) And boxialla=1 And hypyt<2 Then
yvel=2
hypyt+1
EndIf
If KeyHit(19) Then
rn1#=1
rn2#=1.5
rn3#=2
y=h-50
x=50
yvel=0
x2#=51
y2#=h-53
boxialla=1
te=200
sped=4
If pisteet>rpist Then
rpist=pisteet
EndIf
If matka>rmatk Then
rmatk=matka
EndIf
If boostiaika>rboos Then
rboos=boostiaika
EndIf
If napattu>rtahd Then
rtahd=napattu
EndIf
boostiaika=0
pisteet=0
matka=0
napattu=0
m=matka
EndIf
If pisteet>rpist Then
rpist=pisteet
EndIf
If matka>rmatk Then
rmatk=matka
EndIf
If boostiaika>rboos Then
rboos=boostiaika
EndIf
If napattu>rtahd Then
rtahd=napattu
EndIf
Color Max(0,Min(255,255-255*rn11)),Max(0,Min(255,255-255*rn33)),Max(0,Min(255,255-255*rn22))
Text 0,0,"Score : "+pisteet
Text 0,teks,"Meters : "+matka/20+"m"
Text 0,teks*2,"Overall boost : "+boostiaika+"s"
Text 0,teks*3,"Stars Cought : "+napattu
Text 0,teks*4,"Best score : "+rpist
Text 0,teks*5,"Best d"+"istance : "+rmatk/20+"m"
Text 0,teks*6,"Best boost t"+"ime: "+rboos+"s"
Text 0,teks*7,"Most stars cought : "+rtahd
Color 255,170,0
If te>0 Then
CenterText w/2,h-60,"GO!"
te-3
EndIf
If y>h-29 Then
CenterText w/2,h-60,"R t"+"o try again"
EndIf
If y<h Then
matka=matka+spe
y-yvel
EndIf
If y>h-30 And boxialla=1 Then
y=h-30
yvel=0
EndIf
If Timer()>t+askel Then
If y=h-30 Then
f=f+1
Else
f=0
EndIf
t=Timer()
EndIf
If KeyDown(42) Then
If y<h-29 Then
spe=CurveValue(sped+sped/2,spe,10)
If Timer()>paa+1000 Then
boostiaika+1
paa=Timer()
EndIf
x2=CurveValue(x-1,x2,8)
EndIf
Else
spe=CurveValue(sped,spe,10)
x2=CurveValue(x+1,x2,3)
EndIf
For i=0 To rr*10
If Rand(20)=0 Then
s.STAR=New(STAR)
s\x=w
s\yy=Rand(h-100,h-30)
s\y=s\yy
s\jako=Rnd(0.5,3)
s\spe=spe/s\jako
EndIf
Next i
Color 255,170,0
y2=CurveValue(y-4,y2,8)
If y2>y-3 Then y2=y-3
Dot x2,y2
If f>1 Then f=0
SetWindow "The Jump",0,"Your scores won't be saved unless you press esc t"+"o quit"
DrawImage ukko1,x,y-3,f
DrawImage mouse,MouseX(),MouseY()
DrawScreen
If debug=0 Then
ClearText
EndIf
Until KeyHit(1)
Goto menu
optio:
ClearMouse
For i=6 To 8
se.SEL=New(SEL)
se\x=w/2
se\y=vy+(i-5)*(teks+6)
se\c=255
se\id=i
Select i
Case 6
se\txt="Music"
Case 7
se\txt="Debug"
Case 8
se\txt="Background"
EndSelect
Next i
Repeat
For se.SEL=Each SEL
If se\id>5 Then
se\c=127-Min(85,Distance(se\x/10,se\y,mx/10,my)*4)
Select se\id
Case 6
Color 0.2*se\c,0.2*se\c*1.5,0.2*se\c*2
Box se\x-2-TextWidth(se\txt+" "+music)/2,se\y-d*2,TextWidth(se\txt+" "+music)+4,TextHeight(se\txt),1
Color se\c,se\c*1.5,se\c*2
Box se\x-2-TextWidth(se\txt+" "+music)/2,se\y-d*2,TextWidth(se\txt+" "+music)+4,TextHeight(se\txt),0
CenterText se\x,se\y,se\txt+" "+music,2
Case 7
Color 0.2*se\c,0.2*se\c*1.5,0.2*se\c*2
Box se\x-2-TextWidth(se\txt+" "+debug)/2,se\y-d*2,TextWidth(se\txt+" "+debug)+4,TextHeight(se\txt),1
Color se\c,se\c*1.5,se\c*2
Box se\x-2-TextWidth(se\txt+" "+debug)/2,se\y-d*2,TextWidth(se\txt+" "+debug)+4,TextHeight(se\txt),0
CenterText se\x,se\y,se\txt+" "+debug,2
Case 8
Color 0.2*se\c,0.2*se\c*1.5,0.2*se\c*2
Box se\x-2-TextWidth(se\txt+" "+tausta)/2,se\y-d*2,TextWidth(se\txt+" "+tausta)+4,TextHeight(se\txt),1
Color se\c,se\c*1.5,se\c*2
Box se\x-2-TextWidth(se\txt+" "+tausta)/2,se\y-d*2,TextWidth(se\txt+" "+tausta)+4,TextHeight(se\txt),0
CenterText se\x,se\y,se\txt+" "+tausta,2
EndSelect
If Distance(0,se\y,0,my)<8 Then
If MouseHit(1) Or KeyHit(28) Then
If debug=1 Then
AddText se\txt
EndIf
Select se\id
Case 6
music+1
If music>1 Then music=0
Case 7
debug+1
If debug>1 Then debug=0
Case 8
tausta+1
If tausta>1 Then tausta=0
EndSelect
EndIf
EndIf
EndIf
Next se
If debug=0 Then
ClearText
EndIf
mx=MouseX()
my=MouseY()
DrawImage mouse,MouseX(),MouseY()
DrawScreen
Until KeyHit(1)
Goto menu
about:
Repeat
Color 42*1.2,42*1.5,42*1.8
CenterText w/2,10+teks,"This is a typical game"
CenterText w/2,10+teks*2,"where you control a dude"
CenterText w/2,10+teks*3,"which runs f"+"orever"
CenterText w/2,10+teks*4,"Press space To jump"
CenterText w/2,10+teks*5,"R To recover"
CenterText w/2,10+Teks*6,"Shift To boost"
Color 30,30,30
Text w-TextWidth("esc To go back"),h-teks,"Esc t"+"o go back"
DrawScreen
If debug=0 Then
ClearText
EndIf
Until KeyHit(1)
Goto menu
credits:
Repeat
Color 42*1.2,42*1.5,42*1.8
CenterText w/2,10+teks," Code : Elias Linjama"
CenterText w/2,10+teks*2," Musics : Elias Linjama"
CenterText w/2,10+teks*3,"Graphics: Elias Linjama"
Color 30,30,30
Text w-TextWidth("esc To go back"),h-teks,"Esc t"+"o go back"
DrawScreen
If debug=0 Then
ClearText
EndIf
Until KeyHit(1)
Goto menu
loppu:
f=OpenToWrite("score.txt")
WriteInt f,rpist
WriteInt f,rmatk
WriteInt f,rboos
WriteInt f,rtahd
CloseFile f
DeleteFile "ukko.png"
End
meta:
For pa.PAL=Each PAL
pa\x=xx
pa\y=CurveValue(yy,pa\y,10)
pa\kx=MouseX()
pa\ky=MouseY()
If iskut>pa\is Then
pa\y=pa\y-10
pa\is=iskut
EndIf
Next pa
For xt=0 To w Step XST
For yt=0 To h Step YST
c=120
For pa.PAL=Each PAL
dis=(255*pa\s/(Distance(xt,yt,pa\x,pa\y)+1))
c=c+dis
Next pa
c=Min(255,c)
c=Max(0,c)
Color Max(0,Min(255,0+(c*rn11)-yt*2)),Max(0,Min(255,0+(c*rn22)-yt*2)),Max(0,Min(255,0+(c*rn33)-yt*2))
Box xt,yt,XST,YST,1
Next yt
Next xt
Return
fontti pienennetty ja näytön leveyttä/korkeutta voi muuttaa kahden ekan rivin avulla (w=width, h=heigth)
lisätty taustalle suorakulmainen 'vuoristo', jonka saa asetuksista pois (jos kone ei kestä )
lisätty taustalle jotain pientä