HLVSPL/main.CB

133 lines
3.5 KiB
Text
Raw Normal View History

2022-07-23 10:58:34 +03:00
Global mainmargin, btthit, hiiri, font, bigfont, hlpvihu, poistuttu, bgrr, bgrg, bgrb, lvl1spd
poistuttu = False
//Taustav<61>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<79> lehm<68> VS Paha lehm<68>", 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<75><6D>r<EFBFBD>
i = 0
//Lis<69>t<EFBFBD><74>n p<><70>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<6D>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<54>p<EFBFBD>yd<79>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<6D>t tulokset"
PlaySound btthit
highscore()
Case "Tietoja"
PlaySound btthit
credits()
Case "Ty<54>p<EFBFBD>yd<79>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<><70>valikko muuallak<61>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