Code: Select all
Print "Rahaa 100e"
WaitKey
If "Rahaa 100e" Then
Print "Mitä haluat tehdä?"
EndIf
Print "Peli Ohi"
Miksi peli loppuu tohon Mitä haluat tehdä-kohtaan??
Code: Select all
Print "Rahaa 100e"
WaitKey
If "Rahaa 100e" Then
Print "Mitä haluat tehdä?"
EndIf
Print "Peli Ohi"
Code: Select all
Print "Rahaa 100e"
rahat=1
WaitKey
If "Rahaa 100e" And rahat=1 Then
Print "Mitä haluat tehdä?"
Else
Print "Peli Ohi"
EndIf
WaitKey
DrawScreen
Code: Select all
rahamäärä = 100
Code: Select all
rahamäärä = 50
Code: Select all
AddText "Rahamäärä: " + Str(rahamäärä)
DrawScreen
Code: Select all
If rahamäärä = 50 then 'tee jotain
Code: Select all
rahamäärä = 100
AddText "Rahaa " + str(rahamäärä) + "e"
DrawScreen
WaitKey
If rahamäärä = 100 then AddText "Mitä haluat tehdä?" else AddText "Peli ohi"
DrawScreen
WaitKey 'ilman tätä peli sammuu heti
öhh oliskohanSkuller! wrote:Esimerkiksi näin:Code: Select all
Print "Rahaa 100e" rahat=1 WaitKey If "Rahaa 100e" And rahat=1 Then Print "Mitä haluat tehdä?" Else Print "Peli Ohi" EndIf WaitKey DrawScreen
Code: Select all
Print "Rahaa 100e"
rahat=1 // tässäkö tarkotetaan et on 100e?
WaitKey
If rahat = 1 Then
Print "Mitä haluat tehdä?"
Else
Print "Peli Ohi"
EndIf
WaitKey
DrawScreen
No se muuttuja vain tarkottaa siinä sitä että rahaa on edes olemassa, olishan sen voinu vähän järkevämminkin tehä mut se oli vaa nopeesti tehty esimerkki siitä miten se edes toimii.temu92 wrote:öhh oliskohanSkuller! wrote:Esimerkiksi näin:Code: Select all
Print "Rahaa 100e" rahat=1 WaitKey If "Rahaa 100e" And rahat=1 Then Print "Mitä haluat tehdä?" Else Print "Peli Ohi" EndIf WaitKey DrawScreen
edit: deem, harakka ehti ensinCode: Select all
Print "Rahaa 100e" rahat=1 // tässäkö tarkotetaan et on 100e? WaitKey If rahat = 1 Then Print "Mitä haluat tehdä?" Else Print "Peli Ohi" EndIf WaitKey DrawScreen
Sain korjattua muuttamalla yhden satasen nollaksiHarakka wrote:Haluat ilmeisesti saada tarkastettua kuinka paljon rahaa on. Silloin tarvitset muuttujan, johon tallennetaan rahamäärä. Se on näin helppoa:Nyt rahamäärä pysyy tallessa ikuisesti, ellei sitä muuteta. Muuttaminen on yhtä helppoa:Code: Select all
rahamäärä = 100
Jos haluat tulostaa rahamäärän tekstinä näytölle, kannattaa käyttää AddTextiä.Code: Select all
rahamäärä = 50
Str(rahamäärä) muuttaa rahamäärä - muuttujan tekstiksityyppiseksi, koska AddText lisää teksti- eikä numerotyyppistä tieto näytölle. Drawscreen piirtää tekstin, ilman sitä näytöllä näkyy vain mustaa. Jos haluat tarkistaa, onko rahamäärä se 50, tee näin:Code: Select all
AddText "Rahamäärä: " + Str(rahamäärä) DrawScreen
Eli tässä olisi toimiva esimerkki:Code: Select all
If rahamäärä = 50 then 'tee jotain
Code: Select all
rahamäärä = 100 AddText "Rahaa " + str(rahamäärä) + "e" DrawScreen WaitKey If rahamäärä = 100 then AddText "Mitä haluat tehdä?" else AddText "Peli ohi" DrawScreen WaitKey 'ilman tätä peli sammuu heti