RPG Code optimizing and Save feature help
Author |
Message |
LegendsEnd
|
Posted: Sun Oct 09, 2005 10:02 pm Post subject: RPG Code optimizing and Save feature help |
|
|
To begin with, the RPG i'm making goes back to the intro screen after a Game Over and while I have it working, it seems very...hard to keep track of, here's an example I just made. I dislike having that many loops as it begins to get confusing is there any other more efficient way?
code: |
var blah, start : string
var key : string (1)
var GO : boolean
loop
loop
loop
put "New Game"
put "Continue"
get start : *
if start = "New Game" then
exit
elsif start = "Continue" then
loop
put "You lose"
end loop
else
put "Please enter New Game or Continue"
end if
end loop
put "attack"
put "run"
loop
get blah
if blah = "attack" then
put "You attack Bob for 10 damage."
getch (key)
cls
put "Bob retaliates and hits you for 9999 damage."
getch (key)
cls
put "Game Over"
GO := true
exit
elsif blah = "run" then
put "You run away"
exit
else
put "please enter attack or run"
end if
end loop
exit when GO = true
put "Success! After running away you find the legendary shoe of destruction."
end loop
end loop
|
I'm also having trouble figuring out the Save game code. Could someone post an example where someone can run a program, chose to save at a certain point and start with all the variables set at what they were and continue from the same location at the code? Thanks in advance and I appreciate the help. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
TokenHerbz
|
Posted: Sun Oct 09, 2005 10:18 pm Post subject: (No subject) |
|
|
1st off, use procedures, (proc for short)
proc Battle
post code
end battle
proc heal
post code
end heal
loop
Battle
heal
end loop
You want to have 1 main loop ONLY in your game, and atm im a lil busy to find your save feature tutoreal, but in a few i will |
|
|
|
|
|
Cervantes
|
Posted: Mon Oct 10, 2005 8:40 am Post subject: (No subject) |
|
|
To avoid the problem of so many nested loops, you could try hiding using a boolean variable to hide your intro, or to hide the game screen when you're at the intro screen.
Alternatively, you could still have nested loops, just change the appearance of them. You have one main loop which calls several procedures. Those procedures could have loops within them, which could call procedures which have loops within them! But it becomes more managable if you layer things this way.
As for saving, you'll want to write the values of all the important data into files. It would be good if you knew records, and then you could easily use read and write |
|
|
|
|
|
[Gandalf]
|
Posted: Mon Oct 10, 2005 2:22 pm Post subject: (No subject) |
|
|
I'm starting to think that any help thread with "RPG" should be banned. This is not the case in this topic, but often you get some huge code impossible to give help on. If you want to get help for your "RPG" then post small problems, it's easier for the creator to isolate the problem than anyone else. |
|
|
|
|
|
|
|