Code: Select all
'----------------------------------------------------------------
' Viikatemies 1
'----------------------------------------------------------------
SCREEN 900,900
FrameLimit 40
SetWindow "Viikatemies1",0,"oletko varma?"
Type VIHOLLISET
Field obj'objecti
Field hp'energiat
Field dmg'vahinko
Field speed'nopeus
Field score'pisteet
Field id'minkälainen zombie on
Field reload
Field shooting
End Type
Type BULLETS
Field obj
Field hp
Field dmg
Field speed
Field id
End Type
Type ENEMY_BULLETS
Field obj
Field hp
Field dmg
Field speed
Field id
End Type
Type upgs'asepäivitykset
Field obj
Field hp
Field id
EndType
/////////////////////////////////////////////////////////////////
valikko:
ClearText
ClearObjects
kuva = LoadImage ("c:\viikatemies\valikko.png")
uusi = LoadObject("c:\viikatemies\uusi.png")
PositionObject uusi,150,30
poistu = LoadObject("c:\viikatemies\poistu.png")
PositionObject poistu,-150,-30
ohjeet = LoadObject("c:\viikatemies\ohjeet.png")
PositionObject ohjeet,-200,200
hiiri = LoadObject("c:\viikatemies\hiiri.png")
PositionCamera 0, 0
Repeat
DrawImage kuva,50,50
PositionObject hiiri,MouseWX(),MouseWY()
ShowMouse OFF
If ObjectsOverlap(hiiri,uusi) And MouseHit(1) Then Goto alkutekstit
If ObjectsOverlap (hiiri,poistu) And MouseHit(1) Then End
If ObjectsOverlap (hiiri,ohjeet) And MouseHit(1) Then Goto ohjeet
ClearText
DrawScreen
Forever
/////////////////////////////////////////////////////////////////
pause:
ClearObjects
ClearText
pause = LoadImage ("c:\viikatemies\pause.png")
Repeat
DrawImage pause, 0,0
Text 100,100,"Pysäytit Pelin"
Text 100,150," (1) Takaisin peliin"
Text 100,200," (2) Kauppaan"
Text 100,250," (3) Poistu pelistä"
If KeyHit (cbkey1) Then Goto peli
If KeyHit (cbkey2) Then Gosub kauppa
If KeyHit (cbkey3) Then End
DrawScreen
Forever
/////////////////////////////////////////////////////////////////
ohjeet:
arial=LoadFont("arial",20)
Repeat
ClearObjects
DrawImage kuva,50,50
Color cbred
SetFont arial
Text 1,1,"OHJEET PELAAMISEEN"
Text 1,50,"W kävellään eteenpäin"
Text 1,100,"S kävellään taaksepäin"
Text 1,150,"A liikutetaan viikatetta"
Text 1,200,"D liikutetaan viikatetta"
Text 1,250,"Hiiren oikealla ammutaan"
Text 1,300,"Hiirellä käännetään ukkoa"
Text 1,350,"I avataan inventory"
Text 1,400,"Punaiset Pullot parantavat"
Text 1,450,"Siniset Pullot lisäävät voimaa"
Text 1,500,"Vihreät Pullot lisäävät nopeutta"
Text 1,550,"Peli pysäytetään P:llä"
Text 250,50,"450 Vihua Bossiin"
Text 250,100,"Paina K niin Kauppaan"
Color cbblack
Text 100,800,"Paina Enteriä niin pääset valikkoon takaisin"
If KeyDown (28) Then Goto valikko Then ClearText ' 28 = enter
DrawScreen
Forever
/////////////////////////////////////////////////////////////////
alkutekstit:
ClearObjects 'poistaa valikon kuvat
arial=LoadFont("arial",20)
kuva2= LoadImage ("c:\viikatemies\valikko.png")
Repeat
DrawImage kuva2,50,50
SetFont arial
Color cbblack
Text 60,110,"Lisään tekstin myöemmin .."
Text 60,130,"JOtain"
Text 60,150,"LOL"
Text 60,180,"paskaa edeööeen"
Text 60,200,"vieläkin jotain paskaa."
If KeyHit(28) Then
DeleteFont arial
Goto peli '28 = enter
EndIf
DrawScreen
Forever
/////////////peli alkaa tästä////////////////////////////////////
'->
peli:
ClearText
kartta = LoadMap("c:\viikatemies\testi3.til","c:\viikatemies\TILESET.png")
ObjectPickable kartta,1
ukko = LoadObject ("c:\viikatemies\viikatemies.png",72)
SetupCollision ukko, kartta, 1, 4, 2
PositionObject ukko,150,200
RotateObject ukko,270
bullet=LoadObject("c:\viikatemies\myrkkypallo.png",72)
ShowObject bullet,OFF
bullet2=LoadObject("c:\viikatemies\nuoli.png",72)
ShowObject bullet2,OFF
vihu1 = LoadObject ("c:\viikatemies\kirvesmies.png",72) : ShowObject vihu1,OFF
vihu2 = LoadObject ("c:\viikatemies\jousimies.png",72) : ShowObject vihu2,OFF
cow = LoadObject ("c:\viikatemies\ritari.png",32) : ShowObject cow,OFF
upg=LoadObject ("c:\viikatemies\esine1.png") : ShowObject upg,OFF
topower=LoadObject ("c:\viikatemies\esine3.png") : ShowObject topower,OFF
tospeed=LoadObject ("c:\viikatemies\esine2.png") : ShowObject tospeed,OFF
medikit=LoadObject ("c:\viikatemies\esine1.png") : ShowObject medikit,OFF
viikate = LoadObject("c:\viikatemies\viikate3.png",18)
hiiri = LoadObject("c:\viikatemies\hiiri.png")
CloneObjectPosition viikate,ukko
RotateObject viikate, viikateangle + ObjectAngle(ukko)
box1 = LoadImage ("c:\viikatemies\kauppa2.png")
box2 = LoadImage ("c:\viikatemies\kauppa1.png")
pohja =LoadImage ("c:\viikatemies\pohja.png")
hp=2000'sinun energiat
powupg=12'Aseen aloitus teho
speedupg=5'aseen aloitus nopeus
tapot=0 'tappojen määrät
//VARIABLES NEEDED
Const ACCURACY=1 //radar accuracy
Global ang#,fade,speed
ang=0.0 //angle of the pointer
fade=100 //fading speed of the result
speed=7 //speed of the pointer
Repeat
PositionObject hiiri,MouseWX(),MouseWY()'sijoitetaan tähtäin hiiten koordinaatteihin
If pause Then
PointObject ukko,hiiri'käännetään ukko tähtäimeen
If hp>0 Then 'jos on energiaa niin suritetaan kaikki
CloneCameraPosition ukko
If KeyDown(17) Then MoveObject ukko,2' 17 = W
If KeyDown(31) Then MoveObject ukko,-2' 31 =S
If KeyDown(cbkeyA) Then viikateangle = WrapAngle(viikateangle + 10)
If KeyDown(cbkeyD) Then viikateangle = WrapAngle(viikateangle - 10)
CloneObjectPosition viikate,ukko
RotateObject viikate, viikateangle + ObjectAngle(ukko)
UpdateGame
CloneCameraPosition ukko
If MouseHit (1) And reload<0
newBullet.BULLETS= New(BULLETS)
newBullet\obj=CloneObject(bullet)
newbullet\dmg=powupg
newbullet\speed=speedupg
CloneObjectPosition newBullet\obj,ukko
CloneObjectOrientation newbullet\obj,ukko
MoveObject newBullet\obj,24
reload=15
SetupCollision newbullet\obj,kartta,1,4,2
EndIf
reload-1
'Asepäivitykset''''''''''''''''''''''''''''''''
If uusi>220
newupg.upgS= New(upgS)'thdään uusi
newupg\obj=CloneObject(upg)
newupg\hp=100
newupg\id=Rand(1,3)
If Newupg\id=1 Then PaintObject newupg\obj,topower
If Newupg\id=2 Then PaintObject Newupg\obj,tospeed
If Newupg\id=3 Then PaintObject Newupg\obj,medikit
'Asetetaan tavara kohtaan missä ei ole törmäystä
For y=1 To MapWidth()
For x=1 To MapWidth()
If GetMap2(2,x,y)=0 Then PositionObject newupg\obj,Rand(-600,500),Rand(-600,600)
Next x
Next y
uusi=0
EndIf
uusi+1
////VIHOLLISET////
If luo>130'jos luonti on suurempi kuin 130, niin tehdään zombie
newzombi.VIHOLLISET= New(VIHOLLISET)
newzombi\obj=CloneObject(vihu1)
ObjectPickable newzombi\obj,1
'Asetetaan vihollinen kohtaan missä ei ole törmäystä
For y=1 To MapWidth()
For x=1 To MapWidth()
If GetMap2(2,x,y)=0 Then PositionObject newzombi\obj,Rand(-600,500),Rand(-600,600)
Next x
Next y
newzombi\id=Rand(1,3)
If newzombi\id = 1 Then 'Ykkös zombi
newzombi\hp=Rand(90,110):newzombi\dmg=Rand(1,3):newzombi\speed=Rand(2,3):newzombi\score=Rand(10,20)'Asetetaan zombielle kentät
EndIf
If newzombi\id = 2 Then 'kakkos zombi
PaintObject newzombi\obj,cow
newzombi\hp=Rand(110,130):newzombi\dmg=Rand(2,4):newzombi\speed=Rand(1,2):newzombi\score=Rand(35,35)'toiselle myös
EndIf
If newzombi\id = 3 Then 'kolmos zombi
PaintObject newzombi\obj,vihu2
newzombi\hp=Rand(110,130):newzombi\dmg=Rand(2,4):newzombi\speed=Rand(1,2):newzombi\score=Rand(10,25)'toiselle myös
newzombi\shooting = 1 //ampuva zombi
EndIf
SetupCollision newzombi\obj,kartta,1,4,2
luo=0
EndIf
luo+1
For izombi.VIHOLLISET= Each VIHOLLISET'Aloitetaan zombien läpikäynti
'Typerä tekoäly
If ObjectSight (izombi\obj,ukko) And izombi\reload<0 And izombi\shooting = 1 Then
newBullet2.ENEMY_BULLETS= New(ENEMY_BULLETS)
newBullet2\obj=CloneObject(bullet2)
newbullet2\dmg=powupg
newbullet2\speed=speedupg
CloneObjectPosition newBullet2\obj,izombi\obj
CloneObjectOrientation newbullet2\obj,izombi\obj
MoveObject newBullet2\obj,24
izombi\reload=50
SetupCollision newbullet2\obj,kartta,1,4,2
EndIf
sidle=Rand(-20,20)
If CountCollisions(izombi\obj) Then MoveObject izombi\obj,0,sidle'jos kosketaan deinään, niin stepataan
PointObject izombi\obj,ukko'zombi tähtää pelaajaan
If ObjectsOverlap(izombi\obj,ukko) Then hp-izombi\dmg
For ibullet.bullets=Each bullets
If ObjectsOverlap(ibullet\obj,izombi\obj) Then
izombi\hp-ibullet\dmg
ibullet\hp=-1
EndIf
Next ibullet
If Not ObjectSight(izombi\obj, ukko) And izombi\shooting = 1 Then
MoveObject izombi\obj,izombi\speed'liikutetaan zombia nopeutensa verran
EndIf
If ObjectsOverlap (viikate,izombi\obj) Then izombi\hp-1
If izombi\hp<0 Then 'jos zombin energiat loppuu, niin tapetaan se ja annetaan pisteet
score+izombi\score
tapot=tapot+1
DeleteObject izombi\obj
Delete izombi
EndIf
izombi\reload-1
Next izombi
For iupg.upgS= Each upgS'aloitetaan kaikkien päivitysten käsittely
If ObjectsOverlap(iupg\obj,ukko) Then iupg\hp=-1'jos törmätään niin tuhotaan tavara
If iupg\hp<0 Then'jos tuhotaan tavara
If iupg\id=1 Then powupg+1'lisätään aseen tehoa
If iupg\id=1 Then speedupg+1'nopeutta
If iupg\id=3 Then hp+50'lisää energiaa
DeleteObject iupg\obj'poistetaan tavara
Delete iupg'ja sen jasen
EndIf
Next iupg
For iBullet.BULLETS= Each BULLETS
If CountCollisions(ibullet\obj) Then ibullet\hp-32
MoveObject iBullet\obj,6'llikutetaan luotia
If Distance2(iBullet\obj,ukko)>600 Or ibullet\hp<0 Then 'jos...niin tuhotaan ammus
DeleteObject iBullet\obj
Delete iBullet
EndIf
Next iBullet
For eBullet.ENEMY_BULLETS = Each ENEMY_BULLETS
If CountCollisions(ebullet\obj) Then ebullet\hp-32
MoveObject eBullet\obj,6'llikutetaan luotia
If Distance2(eBullet\obj,ukko)>600 Or ebullet\hp<0 Then 'jos...niin tuhotaan ammus
DeleteObject eBullet\obj
Delete eBullet
EndIf
Next eBullet
EndIf
if KeyHit (cbkeyK) Then Gosub kauppa
DrawGame
DrawImage pohja ,0,0
DrawImage box1,300,10
If MouseX()>300 And MouseX()<300+ImageWidth(box1) And MouseY()>10 And MouseY()<10+ImageHeight(box1) And MouseHit(1) And score>199 Then
powupg+5
score-200
if Not score=200 Then
powupg-0
score-0
EndIf
EndIf
DrawImage box2,380,10
If MouseX()>380 And MouseX()<380+ImageWidth(box2) And MouseY()>10 And MouseY()<10+ImageHeight(box2) And MouseHit(1) And score>100 Then
hp+50
score-100
if Not score=100 Then
hp-0
score-0
EndIf
EndIf
Color cbblack
Text 0,0,"FPS"
Text 30,0, FPS()
Color cbblack
Text 45,13,Date()
Text 45,25,Time() 'kello
Text 150,15,"HP "+hp
Text 150,30,"Pisteet "+score
Text 150,0,"tappojen määrä "+tapot
Text 450,5,"mene kauppaan(1)"
If hp<0 Then
Text 500,500,"kuolit"
WaitKey
For iVihollinen.VIHOLLISET = Each VIHOLLISET
DeleteObject iVihollinen\obj
Delete iVihollinen
Next iVihollinen
For iBullet.BULLETS = Each BULLETS
DeleteObject iBullet\obj
Delete iBullet
Next iBullet
For iEnemyBullet.ENEMY_BULLETS = Each BULLETS
DeleteObject iEnemyBullet\obj
Delete iEnemyBullet
Next iEnemyBullet
For iUpg.upgs = Each upgs
DeleteObject iUpg\obj
Delete iUpg
Next iUpg
Goto valikko
EndIf
Else
DrawGame
Color cbblack
Text 100,100,"Paina P:tä niin pause pois"
Text 10,20,"paina jotain"
EndIf
If KeyUp(cbkeyP) Then pause = Not pause
If KeyUp (cbkeyO) Then pause = Not pause Then Goto pause
Radar(50,50,100,ukko,tilemap,300)
DrawScreen
Forever
'---------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////
//KARTTA// ei ole minun!
//kiitokset tuhoojabotille!
Function Radar(x,y,r,obj,map,range#)
//draw base
Color 0,0,0
Circle x-r/2,y-r/2,r,1
Color 100,80,100
oldangle=ObjectAngle(obj) //save the old angle of the guy
For i=ang-fade To ang Step ACCURACY //loop trought a loop
RotateObject obj,i
ObjectPick obj
Dist#=Distance(PickedX(),PickedY(),ObjectX(obj),ObjectY(obj))
If Dist<range Then // if the picked object is in the range of the beam
rdist#=dist/range //make the distance good for the scale of the radar
If pickedobject()=map Then
Color 150,150+Max(i-ang,-110),0
Else //this ain't no wall, shoot it!
Color 200+Max(i-ang,-160),0,0
EndIf
Dot x+Cos(i)*r/2*rDist,y-Sin(i)*r/2*rDist
EndIf
Next i
RotateObject obj,oldangle //restore the old angle of the object
//update and draw teh pointer
ang+speed
Color 0,80,0
EndFunction
///////////////////////////////////////////////////////////////////////
'--------------------------------------------------------------------
kauppa:
ClearObjects
kauppa = LoadImage ("C:\viikatemies\kauppa.png")
DrawGame
DrawImage kauppa ,0,0
Return
Korjasin gosubiksi