Initial commit
24
credits.CB
Normal file
|
@ -0,0 +1,24 @@
|
|||
Function credits()
|
||||
//Luetaan tiedoston sisältö
|
||||
file = OpenToRead("credits")
|
||||
While Not EOF(file)
|
||||
AddText ReadLine(file)
|
||||
Wend
|
||||
CloseFile file
|
||||
|
||||
//Estetään välitön poistuminen
|
||||
ClearKeys
|
||||
ClearMouse
|
||||
|
||||
//Silmukka
|
||||
Repeat
|
||||
If GetKey() <> False Or GetMouse() <> False Then exit
|
||||
DrawScreen
|
||||
Forever
|
||||
|
||||
PlaySound btthit
|
||||
ClearText
|
||||
//Estetääm välitön toiminta
|
||||
ClearKeys
|
||||
ClearMouse
|
||||
EndFunction
|
BIN
files/BGM01.mid
Normal file
BIN
files/ButtonHit.wav
Normal file
18
files/Help
Normal file
|
@ -0,0 +1,18 @@
|
|||
Pelin idea on hyvin yksinkertainen:
|
||||
Olet hyvä lehmä ja sinun täytyy voittaa
|
||||
paha lehmä.
|
||||
|
||||
Menetät elämän jos outo sininen otus
|
||||
osuu sinuun. Voit kuitenkin päihittää
|
||||
sen hyppäämällä sen päälle.
|
||||
|
||||
Saat pisteitä jokaisesta päihitetystä
|
||||
otuksesta ja kerätystä kolikosta, mutta
|
||||
menetät niitä aina kun menetät elämän.
|
||||
|
||||
Lehmää voi liikuttaa nuolinäppäimillä sekä
|
||||
A- ja D-näppäimillä. Hyppääminen hoituu
|
||||
kätevästi ylänuolella, W-näppäimellä tai
|
||||
välilyönnillä.
|
||||
|
||||
Mukavia pelihetkiä!
|
20
files/HighScore
Normal file
|
@ -0,0 +1,20 @@
|
|||
JT
|
||||
58
|
||||
JT
|
||||
31
|
||||
JT
|
||||
29
|
||||
Nimetön
|
||||
166
|
||||
Nimetön
|
||||
166
|
||||
Nimetön
|
||||
38
|
||||
Nimetön
|
||||
104
|
||||
Nimetön
|
||||
25
|
||||
Nimetön
|
||||
27
|
||||
Nimetön
|
||||
86
|
16
files/credits
Normal file
|
@ -0,0 +1,16 @@
|
|||
Tämän pelin on luonut Jarkko
|
||||
yhdessä Henrikin avustuksella.
|
||||
|
||||
Peli on toteutettu CoolBasic-
|
||||
ohjelmalla ja se on testattu
|
||||
Windows XP (2GHz prosessori,
|
||||
512MB RAM) ja Windows 7 (4GHz,
|
||||
8GB RAM) ympäristössä, joista
|
||||
molemmissa toimi moitteettomasti.
|
||||
|
||||
Tahdon kiittää kaikkia testaajia,
|
||||
joiden apu on ollut todella
|
||||
tärkeää ohjelmavirheiden
|
||||
löytämiseksi. Mikäli löydät virheitä,
|
||||
otathan yhteyttä sähköpostilla
|
||||
osoitteeseen jt@jt.dy.fi.
|
BIN
files/cursor.bmp
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
files/klick.wav
Normal file
BIN
files/logo.JPG
Normal file
After Width: | Height: | Size: 32 KiB |
BIN
files/lost.wav
Normal file
BIN
files/lvl1.bmp
Normal file
After Width: | Height: | Size: 257 KiB |
BIN
files/lvl1.til
Normal file
BIN
files/lvl2.bmp
Normal file
After Width: | Height: | Size: 257 KiB |
BIN
files/lvl2.til
Normal file
BIN
files/maali.bmp
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
files/pahis.bmp
Normal file
After Width: | Height: | Size: 8.8 KiB |
BIN
files/pling.wav
Normal file
BIN
files/plop.wav
Normal file
BIN
files/score.bmp
Normal file
After Width: | Height: | Size: 246 B |
BIN
files/ukko.bmp
Normal file
After Width: | Height: | Size: 8.8 KiB |
BIN
files/vihu.bmp
Normal file
After Width: | Height: | Size: 33 KiB |
338
game.CB
Normal file
|
@ -0,0 +1,338 @@
|
|||
|
||||
Global nopeus, vihunopeus#, hyppypower, painovoima#, maxPV#, pisteet, raha_alue, gamebgmfile$, loser, plop, pling, taso
|
||||
|
||||
Type vihut
|
||||
Field obj
|
||||
EndType
|
||||
|
||||
Type vihurajat
|
||||
Field obj
|
||||
EndType
|
||||
|
||||
Type rahat
|
||||
Field obj
|
||||
EndType
|
||||
|
||||
Function game(lvl, score, spd)
|
||||
|
||||
//Asetetaan perusarvot
|
||||
nopeus = 2 * spd // Hahmon liikkumisnopeus
|
||||
vihunopeus = 1 * spd // Vihujen liikkumisnopeus
|
||||
hyppypower = 16 // Ponnistusvoima
|
||||
painovoima = 1.5 // Puoamiskiihtyvyys
|
||||
maxPV = 10 // Suurin putoamisnopeus
|
||||
pisteet = score
|
||||
taso = lvl
|
||||
raha_alue = 15
|
||||
|
||||
//Ladataan resurssit
|
||||
kenttä = LoadMap("lvl" + Str(taso) + ".til", "lvl" + Str(taso) + ".bmp")
|
||||
ukko = LoadAnimObject("ukko.bmp", 30, 25, 0, 4)
|
||||
vihu_kuva = LoadAnimObject("vihu.bmp", 32, 32, 0, 11)
|
||||
ShowObject vihu_kuva, OFF
|
||||
raha_kuva = LoadObject("score.bmp")
|
||||
ShowObject raha_kuva, OFF
|
||||
goal = LoadObject("maali.bmp")
|
||||
plop = LoadSound("plop.wav")
|
||||
pling = LoadSound("pling.wav")
|
||||
loser = LoadSound("lost.wav")
|
||||
|
||||
//Kartan läpikäynti
|
||||
For x = 1 To MapWidth()
|
||||
For y = 1 To MapHeight()
|
||||
Select GetMap2(3, x, y)
|
||||
Case 1 //Pelaaja löytyi
|
||||
ObjectToMap(ukko, kenttä, x, y)
|
||||
CloneCameraPosition ukko
|
||||
SetupCollision ukko, kenttä, 1, 4, 2
|
||||
ObjectFloat ukko, 0 //Putoamisvauhti 0
|
||||
ObjectInteger ukko, False //Jalat irti maasta
|
||||
Case 2 //Vihu löytyi
|
||||
vihu.vihut = New(vihut)
|
||||
vihu\obj = CloneObject(vihu_kuva)
|
||||
ObjectString vihu\obj, Str(-1) //Suunta vasemmalle
|
||||
ObjectFloat vihu\obj, 0 //Putoamisvauhti 0
|
||||
ObjectInteger vihu\obj, False //Jalat irti maasta
|
||||
LoopObject vihu\obj, 0, 10, 0.1 * spd, OFF
|
||||
ObjectRange vihu\obj, ObjectSizeX(kenttä) / MapWidth(), ObjectSizeY(kenttä) / MapHeight()
|
||||
SetupCollision vihu\obj, kenttä, 1, 4, 2
|
||||
SetupCollision vihu\obj, ukko, 1, 1, 2
|
||||
SetupCollision ukko, vihu\obj, 1, 1, 2
|
||||
ObjectToMap(vihu\obj, kenttä, x, y)
|
||||
Case 3 //Piste löytyi
|
||||
raha.rahat = New(rahat)
|
||||
raha\obj = CloneObject(raha_kuva)
|
||||
SetupCollision ukko, raha\obj, 1, 1, 2
|
||||
ObjectRange raha\obj, raha_alue, raha_alue
|
||||
ObjectToMap(raha\obj, kenttä, x, y)
|
||||
Case 4 //Vihollisen alueen raja löytyi
|
||||
vihuraja.vihurajat = New(vihurajat)
|
||||
vihuraja\obj = MakeObject()
|
||||
ObjectRange vihuraja\obj, ObjectSizeX(kenttä) / MapWidth(), ObjectSizeY(kenttä) / MapHeight()
|
||||
ObjectToMap(vihuraja\obj, kenttä, x, y)
|
||||
Case 5 //Maali löytyi
|
||||
SetupCollision ukko, goal, 1, 1, 2
|
||||
objecttomap(goal, kenttä, x, y)
|
||||
EndSelect
|
||||
Next y
|
||||
Next x
|
||||
For vihu.vihut = Each vihut
|
||||
For vihuraja.vihurajat = Each vihurajat
|
||||
SetupCollision vihu\obj, vihuraja\obj, 1, 1, 2
|
||||
SetupCollision vihuraja\obj, vihu\obj, 1, 1, 2
|
||||
Next vihuraja
|
||||
Next vihu
|
||||
|
||||
CameraFollow ukko, 1, 5
|
||||
Color 255, 255, 255
|
||||
ClsColor 0, 0, 0
|
||||
|
||||
// Säälittävä ruutunopeus, koska optimointi omalle heikolle koneelleni...
|
||||
FrameLimit 30
|
||||
|
||||
///Pääsilmukka
|
||||
|
||||
Repeat
|
||||
|
||||
|
||||
//Nollataan maassa-muuttujat
|
||||
ObjectInteger ukko, False
|
||||
For vihu.vihut = Each vihut
|
||||
ObjectInteger vihu\obj, False
|
||||
Next vihu
|
||||
|
||||
//Tarkistetaan ja käsitellään törmäykset
|
||||
//Pelaaja:
|
||||
törmäykset = CountCollisions(ukko)
|
||||
|
||||
For i = 1 To törmäykset
|
||||
|
||||
//Tarkistetaan pelaajan ja kentän törmäykset
|
||||
If GetCollision(ukko, i) = kenttä Then
|
||||
If CollisionAngle(ukko, i) = 90 And (Not jumped) Then // Maa?
|
||||
ObjectInteger ukko, True
|
||||
ObjectFloat ukko, 0
|
||||
ElseIf CollisionAngle(ukko, i) = 270 Then // Katto?
|
||||
ObjectFloat ukko, 0
|
||||
EndIf
|
||||
EndIf
|
||||
|
||||
//Tarkistetaan pelaajan ja vihujen törmäykset
|
||||
For vihu.vihut = Each vihut
|
||||
If GetCollision(ukko, i) = vihu\obj Then
|
||||
If CollisionAngle(ukko, i) > 45 And CollisionAngle(ukko, i) < 135 Then
|
||||
ObjectFloat ukko, hyppypower
|
||||
DeleteObject vihu\obj
|
||||
Delete vihu
|
||||
PlaySound plop
|
||||
pisteet = pisteet + 10
|
||||
Else
|
||||
lost()
|
||||
Return False
|
||||
EndIf
|
||||
EndIf
|
||||
Next vihu
|
||||
|
||||
//Tarkistetaan pelaajan ja rahojen törmäykset
|
||||
For raha.rahat = Each rahat
|
||||
If GetCollision(ukko, i) = raha\obj Then
|
||||
PlaySound pling
|
||||
DeleteObject raha\obj
|
||||
pisteet = pisteet + 1
|
||||
Delete raha
|
||||
EndIf
|
||||
Next raha
|
||||
Next i
|
||||
|
||||
//Tarkistetaan pelaajan maaliin saapuminen
|
||||
If GetCollision(ukko, i) = goal Then
|
||||
won()
|
||||
Return False
|
||||
EndIf
|
||||
|
||||
//Vihut:
|
||||
For vihu.vihut = Each vihut
|
||||
|
||||
törmäykset = CountCollisions(vihu\obj)
|
||||
|
||||
For i = 1 To törmäykset
|
||||
|
||||
//Tarkistetaan vihun ja kentän törmäykset
|
||||
If GetCollision(vihu\obj, i) = kenttä Then
|
||||
If CollisionAngle(vihu\obj, i) = 90 Then //Maa
|
||||
ObjectInteger vihu\obj, True
|
||||
ObjectFloat vihu\obj, 0
|
||||
ElseIf CollisionAngle(vihu\obj, i) = 270 Then //Katto
|
||||
ObjectFloat vihu\obj, 0
|
||||
ElseIf CollisionAngle(vihu\obj, i) = 180 Then //Vasen?
|
||||
ObjectString vihu\obj, Str(-1)
|
||||
ElseIf CollisionAngle(vihu\obj,i) = 0 Then //Oikea?
|
||||
ObjectString vihu\obj, Str(1)
|
||||
EndIf
|
||||
EndIf
|
||||
|
||||
//Tarkistetaan vihujen ja vihurajojen törmäykset
|
||||
For vihuraja.vihurajat = Each vihurajat
|
||||
If GetCollision(vihu\obj, i) = vihuraja\obj Then
|
||||
If CollisionAngle(vihu\obj, i) >= 90 And CollisionAngle(vihu\obj, i) < 270 Then //Vasen?
|
||||
ObjectString vihu\obj, Str(-1)
|
||||
Else //Oikea?
|
||||
ObjectString vihu\obj, Str(1)
|
||||
EndIf
|
||||
EndIf
|
||||
Next vihuraja
|
||||
|
||||
//Tarkistetaan vihujen ja pelaajan törmäykset
|
||||
If GetCollision(vihu\obj, i) = ukko Then
|
||||
If CollisionAngle(ukko, i) < 45 And CollisionAngle(ukko, i) > 135 Then
|
||||
ObjectFloat ukko, hyppypower
|
||||
DeleteObject vihu\obj
|
||||
Delete vihu
|
||||
PlaySound plop
|
||||
pisteet = pisteet + 10
|
||||
Else
|
||||
lost()
|
||||
Return False
|
||||
EndIf
|
||||
EndIf
|
||||
Next i
|
||||
Next vihu
|
||||
|
||||
//Näppäinten tarkistukset
|
||||
If LeftKey() Or KeyDown(cbkeya) Then
|
||||
PlayObject ukko, 2, 3, 0.1 * spd, OFF
|
||||
MoveObject ukko, -nopeus
|
||||
ElseIf RightKey() or KeyDown(cbkeyd) Then
|
||||
PlayObject ukko, 0, 1, 0.1 * spd, OFF
|
||||
MoveObject ukko, nopeus
|
||||
EndIf
|
||||
If Keyhit(cbKeyQ) Then
|
||||
' won()
|
||||
' Return False
|
||||
Else
|
||||
FrameLimit 30
|
||||
EndIf
|
||||
If ObjectInteger(ukko) And (UpKey() Or KeyHit(cbkeyspace) Or Keyhit(cbkeyw)) Then
|
||||
ObjectFloat ukko, hyppypower
|
||||
'jumped = True
|
||||
EndIf
|
||||
|
||||
|
||||
//Käsitellään painovoima
|
||||
ObjectFloat ukko, ObjectFloat(ukko) - painovoima
|
||||
If ObjectFloat(ukko) < -maxPV Then ObjectFloat ukko, -maxPV
|
||||
TranslateObject ukko, 0, ObjectFloat(ukko)
|
||||
For vihu.vihut = Each vihut
|
||||
ObjectFloat vihu\obj, ObjectFloat(vihu\obj) - painovoima
|
||||
If ObjectFloat(vihu\obj) < -maxPV Then ObjectFloat vihu\obj, -maxPV
|
||||
TranslateObject vihu\obj, vihunopeus * Int(ObjectString(vihu\obj)), ObjectFloat(vihu\obj)
|
||||
Next vihu
|
||||
|
||||
//Tarkistetaan, ettei pudottu liikaa
|
||||
If ObjectY(ukko) < ObjectY(kenttä) - ObjectSizeY(kenttä) / 2 Then
|
||||
lost()
|
||||
Return False
|
||||
EndIf
|
||||
|
||||
///Kaikki itsestään selvä, mikä nyt kuitenkin ON täällä
|
||||
AddText "Scr: " + Str(pisteet)
|
||||
DrawScreen
|
||||
ClearText
|
||||
Forever
|
||||
ClearObjects
|
||||
EndFunction
|
||||
|
||||
Function lost()
|
||||
|
||||
PlaySound loser
|
||||
Color 10, 10, 10
|
||||
ClsColor 255, 0, 0
|
||||
|
||||
//Poistetaan objektit
|
||||
ClearObjects
|
||||
|
||||
//Tyhjennetään tyypit
|
||||
For vihu.vihut = Each vihut
|
||||
Delete vihu
|
||||
Next vihu
|
||||
For raha.rahat = Each rahat
|
||||
Delete raha
|
||||
Next raha
|
||||
For vihuraja.vihurajat = Each vihurajat
|
||||
Delete vihuraja
|
||||
Next vihuraja
|
||||
|
||||
//Poistetaan napit
|
||||
Nappi_Poista()
|
||||
|
||||
//Lopetuskysymys
|
||||
AddText "Hävisit. Pisteesi: " + Str(pisteet)
|
||||
Nappi_Lisaa(mainmargin, ScreenHeight() / 2 - 10, ScreenWidth() - mainmargin * 2, 20, "Poistu")
|
||||
ClearKeys
|
||||
|
||||
Repeat
|
||||
|
||||
nimi$ = Input("Anna nimesi: ")
|
||||
Nappi_Piirra()
|
||||
If Nappi_Paivita() = "Poistu" Or KeyHit(cbkeyreturn) Then
|
||||
CloseInput
|
||||
If nimi = "" Then nimi = "Nimetön"
|
||||
lisaahs(nimi, pisteet)
|
||||
sound = PlaySound("buttonhit.wav")
|
||||
ClsColor bgrr, bgrg, bgrb
|
||||
Return False
|
||||
EndIf
|
||||
|
||||
DrawScreen
|
||||
|
||||
Forever
|
||||
|
||||
EndFunction
|
||||
|
||||
Function won()
|
||||
|
||||
Color 10, 10, 10
|
||||
ClsColor 0, 255, 0
|
||||
|
||||
//Poistetaan objektit
|
||||
ClearObjects
|
||||
|
||||
//Tyhjennetään Type-jutut
|
||||
For vihu.vihut = Each vihut
|
||||
Delete vihu
|
||||
Next vihu
|
||||
For raha.rahat = Each rahat
|
||||
Delete raha
|
||||
Next raha
|
||||
For vihuraja.vihurajat = Each vihurajat
|
||||
Delete vihuraja
|
||||
Next vihuraja
|
||||
|
||||
//Poistetaan napit
|
||||
Nappi_Poista()
|
||||
|
||||
//Lopetuskysymys
|
||||
AddText "Voitit. Pisteesi: " + Str(pisteet)
|
||||
Nappi_Lisaa(mainmargin, ScreenHeight() / 2 - 10, ScreenWidth() - mainmargin * 2, 20, "Poistu")
|
||||
ClearKeys
|
||||
|
||||
Repeat
|
||||
|
||||
nimi$ = Input("Anna nimesi: ")
|
||||
Nappi_Piirra()
|
||||
If Nappi_Paivita() = "Poistu" Or KeyHit(cbkeyreturn) Then
|
||||
CloseInput
|
||||
If nimi = "" Then nimi = "Nimetön"
|
||||
lisaahs(nimi, pisteet)
|
||||
sound = PlaySound("buttonhit.wav")
|
||||
ClsColor bgrr, bgrg, bgrb
|
||||
nextlvl = taso + 1
|
||||
If FileExists("lvl" + nextlvl + ".til") Then game(taso + 1, pisteet, 3)
|
||||
Return False
|
||||
EndIf
|
||||
|
||||
DrawScreen
|
||||
|
||||
Forever
|
||||
|
||||
EndFunction
|
76
help.CB
Normal file
|
@ -0,0 +1,76 @@
|
|||
Function help()
|
||||
//Näytetään vihun kuva
|
||||
ShowObject hlpvihu, ON
|
||||
|
||||
ClearText
|
||||
|
||||
Locate mainmargin, 3
|
||||
|
||||
//Ladataan tiedoston sisältö
|
||||
file = OpenToRead("Help")
|
||||
While Not EOF(file)
|
||||
AddText Str(ReadLine(file))
|
||||
Wend
|
||||
CloseFile file
|
||||
|
||||
//Välittömän poistumisen esto
|
||||
ClearKeys
|
||||
ClearMouse
|
||||
|
||||
Repeat
|
||||
Nappi_Poista()
|
||||
//Lisätään vihuteksti tarvittaessa
|
||||
If MouseWX() > ObjectX(hlpvihu) - ObjectSizeX(hlpvihu) / 2 - 3 And MouseWY() > ObjectY(hlpvihu) - ObjectSizeY(hlpvihu) / 2 - 3 And MouseWX() < ObjectX(hlpvihu) + ObjectSizeX(hlpvihu) / 2 + 3 And MouseWY() < ObjectY(hlpvihu) + ObjectSizeY(hlpvihu) / 2 + 3 Then
|
||||
Nappi_Lisaa(MouseX() - TextWidth("Outo sininen otus") / 2 - 40, MouseY() + ImageHeight(hiiri) / 2, TextWidth("Outo sininen otus") + 20, 20, "Outo sininen otus")
|
||||
EndIf
|
||||
|
||||
//Pelinaloitus
|
||||
Nappi_Lisaa(ScreenWidth() - ScreenWidth() / 3, ScreenHeight() - mainmargin - 45, ScreenWidth() / 3 - mainmargin, 20, "Aloita Peli")
|
||||
Nappi_Lisaa(ScreenWidth() - ScreenWidth() / 3, ScreenHeight() - mainmargin - 20, ScreenWidth() / 3 - mainmargin, 20, "Takaisin")
|
||||
Nappi_Piirra()
|
||||
|
||||
//Tarkistetaan näppäimistö
|
||||
If KeyHit(cbkeyreturn) Then
|
||||
PlaySound btthit
|
||||
ClearText
|
||||
ClearKeys
|
||||
ClearMouse
|
||||
SetFont font
|
||||
ShowObject hlpvihu, OFF
|
||||
Return True
|
||||
ElseIf KeyHit(cbkeybackspace) Then
|
||||
ClearText
|
||||
ClearObjects
|
||||
PlaySound btthit
|
||||
loadbasicres()
|
||||
Return False
|
||||
EndIf
|
||||
|
||||
//Tarkistetaan nappulat
|
||||
Select Nappi_Paivita()
|
||||
Case "Aloita Peli"
|
||||
PlaySound btthit
|
||||
ClearText
|
||||
ClearKeys
|
||||
ClearMouse
|
||||
SetFont font
|
||||
ShowObject hlpvihu, OFF
|
||||
Return True
|
||||
Case "Takaisin"
|
||||
ClearText
|
||||
ClearObjects
|
||||
PlaySound btthit
|
||||
loadbasicres()
|
||||
Return False
|
||||
EndSelect
|
||||
DrawScreen
|
||||
Forever
|
||||
|
||||
//Poistutaan
|
||||
PlaySound btthit
|
||||
ClearText
|
||||
ClearKeys
|
||||
ClearMouse
|
||||
SetFont font
|
||||
ShowObject hlpvihu, OFF
|
||||
EndFunction
|
75
highscore.cb
Normal file
|
@ -0,0 +1,75 @@
|
|||
Type hslist
|
||||
Field nimi$
|
||||
Field pisteet
|
||||
EndType
|
||||
|
||||
Function highscore()
|
||||
//Ladataan pisteet
|
||||
loadhs()
|
||||
|
||||
//Estetään välitön poistuminen
|
||||
ClearKeys
|
||||
ClearMouse
|
||||
|
||||
//Silmukka
|
||||
Repeat
|
||||
If GetKey() > 0 Or GetMouse() > 0 Then Exit
|
||||
|
||||
ClearText
|
||||
|
||||
//Otsikko
|
||||
AddText "10 viimeisintä tulosta:"
|
||||
|
||||
//Loppujen sijoitus
|
||||
Locate 20, 20
|
||||
|
||||
//Lisätään pisteet näytölle
|
||||
i = 1
|
||||
For hs.hslist = Each hslist
|
||||
AddText Str(i) + ". " + hs\nimi + ": " + Str(hs\pisteet)
|
||||
i = i + 1
|
||||
Next hs
|
||||
|
||||
//Vielä näytön piirto
|
||||
DrawScreen
|
||||
Forever
|
||||
|
||||
//Näytön tyhjäys ja tahattoman klikkauksen esto
|
||||
PlaySound btthit
|
||||
ClearText
|
||||
ClearKeys
|
||||
ClearMouse
|
||||
EndFunction
|
||||
|
||||
Function loadhs()
|
||||
//Alustetaan pistelista
|
||||
For hs.hslist = Each hslist
|
||||
Delete hs
|
||||
Next hs
|
||||
|
||||
//Ladataan pisteet listaan
|
||||
file = OpenToEdit("HighScore")
|
||||
For i = 1 To 10
|
||||
hs.hslist = New(hslist)
|
||||
hs\nimi = ReadLine(file)
|
||||
hs\pisteet = ReadLine(file)
|
||||
Next i
|
||||
|
||||
//Suljetaan tiedosto
|
||||
CloseFile file
|
||||
EndFunction
|
||||
|
||||
Function lisaahs(name$, score)
|
||||
loadhs()
|
||||
nhs.hslist = New(hslist)
|
||||
nhs\nimi = name
|
||||
nhs\pisteet = score
|
||||
Insert nhs, First(hslist)
|
||||
Delete Last(hslist)
|
||||
file = OpenToWrite("highscore")
|
||||
For hs.hslist = Each hslist
|
||||
WriteLine file, hs\nimi
|
||||
WriteLine file, hs\PIsteet
|
||||
Next hs
|
||||
CloseFile file
|
||||
EndFunction
|
BIN
logo/logo.JPG
Normal file
After Width: | Height: | Size: 32 KiB |
BIN
logo/logo.bmp
Normal file
After Width: | Height: | Size: 1,000 KiB |
BIN
logo/logo.xcf
Normal file
BIN
logo/logo_phone.bmp
Normal file
After Width: | Height: | Size: 48 KiB |
BIN
logo/logo_phone.xcf
Normal file
BIN
logo/pahis.bmp
Normal file
After Width: | Height: | Size: 518 B |
133
main.CB
Normal file
|
@ -0,0 +1,133 @@
|
|||
Global mainmargin, btthit, hiiri, font, bigfont, hlpvihu, poistuttu, bgrr, bgrg, bgrb, lvl1spd
|
||||
poistuttu = False
|
||||
|
||||
//Taustavärin asetus
|
||||
bgrr = 200
|
||||
bgrg = 0
|
||||
bgrb = 0
|
||||
|
||||
// Tasojen nopeudet
|
||||
lvl1spd = 3
|
||||
|
||||
//Lopun lähdekoodin hakeminen
|
||||
Include "nappi.cb"
|
||||
Include "help.cb"
|
||||
Include "highscore.cb"
|
||||
Include "credits.cb"
|
||||
Include "game.cb"
|
||||
|
||||
SCREEN 640, 480, 0, 2
|
||||
ChDir "files"
|
||||
Color 10, 10, 10
|
||||
ClsColor bgrr, bgrg, bgrb
|
||||
|
||||
mainmargin = 10
|
||||
|
||||
loadbasicres()
|
||||
|
||||
Function loadbasicres()
|
||||
SetWindow "Hyvä lehmä VS Paha lehmä", 3
|
||||
|
||||
//Ladataan resurssit
|
||||
hiiri = LoadImage("cursor.bmp")
|
||||
btthit = LoadSound("buttonhit.wav")
|
||||
bgm = PlaySound("BGM01.Mid", 20)
|
||||
bgm = PlaySound("BGM01.Mid", 20)
|
||||
font = LoadFont("Comic sans ms", 18)
|
||||
bigfont = LoadFont("Comic sans ms", 30, 1)
|
||||
hlpvihu = LoadAnimobject("vihu.bmp", 32, 32, 0, 11)
|
||||
LoopObject hlpvihu, 0, 10, 0.1, OFF
|
||||
ScreenPositionObject hlpvihu, ScreenWidth() - 32 - mainmargin, 32 + mainmargin
|
||||
ShowObject hlpvihu, OFF
|
||||
SetFont font
|
||||
ShowMouse hiiri
|
||||
|
||||
//Poistetaan turhat napit
|
||||
Nappi_Poista()
|
||||
//Alustetaan nappien lukumäärä
|
||||
i = 0
|
||||
//Lisätään päävalikon napit
|
||||
Nappi_Lisaa(mainmargin, mainmargin + 15 * 0 + 28 * i, ScreenWidth()-2*mainmargin, 20, "Uusi Peli"):i = i + 1
|
||||
Nappi_Lisaa(mainmargin, mainmargin + 15 * 1 + 28 * i, ScreenWidth()-2*mainmargin, 20, "Viimeisimmät tulokset"):i = i + 1
|
||||
Nappi_Lisaa(mainmargin, mainmargin + 15 * 2 + 28 * i, ScreenWidth()-2*mainmargin, 20, "Pikaopas"):i = i + 1
|
||||
Nappi_Lisaa(mainmargin, mainmargin + 15 * 2 + 28 * i, ScreenWidth()-2*mainmargin, 20, "Tietoja"):i = i + 1
|
||||
Nappi_Lisaa(mainmargin, mainmargin + 15 * 3 + 28 * i, ScreenWidth()-2*mainmargin, 20, "Työpöydän taustakuva"):i = i + 1
|
||||
Nappi_Lisaa(mainmargin, mainmargin + 15 * 4 + 28 * i, ScreenWidth()-2*mainmargin, 20, "Lopeta Peli"):i = i + 1
|
||||
Nappi_Lisaa(mainmargin, mainmargin + 15 * 5 + 28 * i, ScreenWidth()-2*mainmargin, 20, "Lvl 2"):i = i + 1
|
||||
EndFunction
|
||||
|
||||
Repeat
|
||||
Nappi_Piirra()
|
||||
DrawScreen
|
||||
|
||||
If KeyHit(cbkeyreturn) Then
|
||||
PlaySound btthit
|
||||
If help() Then
|
||||
lataus()
|
||||
game(1, 0, lvl1spd)
|
||||
palauta()
|
||||
EndIf
|
||||
EndIf
|
||||
|
||||
Select Nappi_Paivita()
|
||||
Case "Uusi Peli"
|
||||
PlaySound btthit
|
||||
If help() Then
|
||||
lataus()
|
||||
game(1, 0, lvl1spd)
|
||||
palauta()
|
||||
EndIf
|
||||
Case "Pikaopas"
|
||||
PlaySound btthit
|
||||
If help() Then
|
||||
poistuttu = True
|
||||
game(1, 0, lvl1spd)
|
||||
palauta()
|
||||
EndIf
|
||||
Case "Viimeisimmät tulokset"
|
||||
PlaySound btthit
|
||||
highscore()
|
||||
Case "Tietoja"
|
||||
PlaySound btthit
|
||||
credits()
|
||||
Case "Työpöydän taustakuva"
|
||||
PlaySound btthit
|
||||
Execute "logo.jpg"
|
||||
Case "Lopeta Peli"
|
||||
sound = PlaySound(btthit)
|
||||
While SoundPlaying(sound) : Wend
|
||||
End
|
||||
Case "Lvl 2"
|
||||
PlaySound btthit
|
||||
lataus()
|
||||
game(2, 0, lvl1spd)
|
||||
palauta()
|
||||
EndSelect
|
||||
|
||||
//Palautetaan päävalikko muuallakäynnin jälkeen
|
||||
If poistuttu Then
|
||||
|
||||
EndIf
|
||||
Forever
|
||||
|
||||
Function lataus()
|
||||
SetFont bigfont
|
||||
CenterText ScreenWidth() / 2, ScreenHeight() / 2, "Ladataan...", 2
|
||||
DrawScreen
|
||||
SetFont font
|
||||
EndFunction
|
||||
|
||||
Function palauta()
|
||||
ClearText
|
||||
Locate ScreenWidth() / 2 - TextWidth("Pisteesi: " + Str(pisteet)) / 2, ScreenHeight() - TextHeight("Pisteesi: " + Str(pisteet))
|
||||
AddText "Pisteesi: " + Str(pisteet)
|
||||
loadbasicres()
|
||||
EndFunction
|
||||
|
||||
Function ObjectToMap(objekti, kartta, x, y)
|
||||
mapX = ObjectSizeX(kartta)
|
||||
mapY = ObjectSizeY(kartta)
|
||||
tileX = mapX / MapWidth()
|
||||
tileY = mapY / MapHeight()
|
||||
PositionObject objekti, (ObjectX(kartta)-mapX/2)+tileX*(X-1)+tileX/2, (ObjectY(kartta)+mapY/2)-tileY*(Y-1)-tileY/2
|
||||
EndFunction
|
72
nappi.CB
Normal file
|
@ -0,0 +1,72 @@
|
|||
Type Nappi
|
||||
Field x
|
||||
Field y
|
||||
Field w
|
||||
Field h
|
||||
Field txt As String
|
||||
EndType
|
||||
|
||||
Function Nappi_Lisaa(x, y, w, h, txt$ = "")
|
||||
unappi.Nappi = New (Nappi)
|
||||
unappi\x = x
|
||||
unappi\y = y
|
||||
unappi\w = w
|
||||
unappi\h = h
|
||||
unappi\txt = txt
|
||||
EndFunction
|
||||
|
||||
Function Nappi_Poista(pnappi$ = "")
|
||||
If pnappi = ""
|
||||
For nappula.Nappi = Each Nappi
|
||||
Delete nappula
|
||||
Next nappula
|
||||
Else
|
||||
For nappula.Nappi = Each Nappi
|
||||
If nappula\txt = pnappi Then Delete nappula
|
||||
Next nappula
|
||||
EndIf
|
||||
EndFunction
|
||||
|
||||
Function Nappi_Piirra()
|
||||
//Otetaan vanha väri talteen
|
||||
r = getRGB(RED)
|
||||
g = getRGB(GREEN)
|
||||
b = getRGB(BLUE)
|
||||
|
||||
For nappula.Nappi = Each Nappi
|
||||
If MouseX() > nappula\x And MouseX() < nappula\x + nappula\w And MouseY() > nappula\y And MouseY() < nappula\y + nappula\h Then
|
||||
For i = 0 To 10
|
||||
x = 210 - i * 5
|
||||
Color x, x, x
|
||||
Box nappula\x + i, nappula\y + i, nappula\w - i * 2, nappula\h - i * 2, 1
|
||||
Next i
|
||||
Else
|
||||
For i = 0 To 10
|
||||
x = 100 + i * 5
|
||||
Color x, x, x
|
||||
Box nappula\x + i, nappula\y + i, nappula\w - i * 2, nappula\h - i * 2, 1
|
||||
Next i
|
||||
EndIf
|
||||
|
||||
//Tulostetaan nappulan teksti
|
||||
Color 0, 0, 0
|
||||
CenterText nappula\x + nappula\w / 2, nappula\y + nappula\h / 2, nappula\txt, 2
|
||||
Next nappula
|
||||
|
||||
//Palautetaan vanha väri
|
||||
Color r, g, b
|
||||
EndFunction
|
||||
|
||||
Function Nappi_Paivita$()
|
||||
'Tarkistetaan, onko hiirellä edes klikattu
|
||||
|
||||
If MouseHit(1) Then
|
||||
'Käydään läpi kaikki nappulat
|
||||
For nappula.Nappi = Each Nappi
|
||||
If MouseX() > nappula\x And MouseX() < nappula\x + nappula\w And MouseY() > nappula\y And MouseY() < nappula\y + nappula\h Then
|
||||
Return nappula\txt
|
||||
EndIf
|
||||
Next nappula
|
||||
EndIf
|
||||
Return ""
|
||||
EndFunction
|