ok so i have a couple of things to ask of you.
Im fairly new to the programing world, and i started out going head over heels into a 2d game that i just couldnt manage. once i realized that i was in over my head i gave up on it for a bit scrapped everything i knew and decided to relearn everything. i took some time to go through tdk's tutorials im currently on #4.
it was easy seeing as how i already memorized the db language after completing the fourth tutorial i started a project call castle fight. its just a simple boring text based combat game, that i used to implement the basics i covered.
anyway here is what iv got so far. i was hoping you could read over it and critique my theory and let me know if its easy to read, structured right, and all that jazz.
Rem Project: Castle_fight
Rem Created: Sunday, October 30, 2011
Rem ***** Main Source File *****
rem begin game source code
rem *************************************
gosub setup
gosub setvariables
gosub invsetup
gosub loadlast
rem main loop
do
rem check to see if menu has/needs to be displayed
if menu = 0 then gosub menuscreen
rem if player selected new game then show newgame screen
if newgame = 1 then gosub newgamestart
if battlebegin = 1
gosub battle
endif
loop
rem subroutines start here
rem ************************************************
setup:
rem clear the screen
cls
rem set resoloution
rem hide mouse
hide mouse
rem set random seed
randomize timer()
rem end setup
return
setvariables:
rem variables for the main menu
menu = 0
rem variables for a new game
newgame = 0
rem variables for the battle
battlebegin = 1
ingamemenuselection$ = ""
rem create player and enemy arrays
dim enemy(3)
dim player(3)
rem temporary array for storing old information from savegame file
dim temparray(4)
savegamefile$ = "savegame.dat"
return
menuscreen:
print "Castle fight!"
print "please choose an option"
print
print "1: new game"
print "2: load game"
print "3: tutorial"
rem gather players choice and set variable
input "", menuselection
rem conditional statements for players choice
if menuselection = 2
rem load previous game stats
rem place stats into array from temparray
enemy(1) = temparray(1)
enemy(2) = temparray(2)
player(1) = temparray(3)
player(2) = temparray(4)
rem turn off the main menu
menu = 1
rem battle is ready to begin
battlebegin = 1
ENDIF
if menuselection => 3
rem print tutorial
print
print "this is the tutorial"
print
wait key
battlebegin = 0
ENDIF
if menuselection =< 1
rem set newgame to 1 so that a new game will be started
newgame = 1
menu = 1
ENDIF
cls
return
invsetup:
rem setup names of weapons and store in array
dim inv$(3)
inv$(1) = "sword"
inv$(2) = "hammer"
inv$(3) = "axe"
rem setup dmg of weapons
dim invdmg(3)
invdmg(1) = 5
invdmg(2) = 2
invdmg(3) = 3
return
newgamestart:
rem set variables for a new game
enemy(1) = 100
enemy(2) = rnd(2)+1
player(1) = 100
player(2) = 1
print
print "please select a weapon"
print "1: sword - 5 damage"
print "2: hammer - 2 damage"
print "3: axe - 3 damage"
print
rem get the players choice and store as weaponchoice
input "", weaponchoice
cls
rem store chosen weapon in array
if weaponchoice =< 1 then player(2) = 1
if weaponchoice = 2 then player(2) = 2
if weaponchoice => 3 then player(2) = 3
print "you have selected the " + inv$(player(2))
print "the battle begins..."
wait key
cls
newgame = 0
battlebegin = 1
return
battle:
rem set enemys dmg multiplyer and damage of strike
enemy(3) = rnd(3)
enemydos = invdmg(enemy(2)) * enemy(3)
rem set your damage multiplyer and damage of strike
player(3) = rnd(3)
playerdos = invdmg(player(2)) * player(3)
rem adjust enemy health from dos
enemy(1) = enemy(1) - playerdos
rem adjust play health from dos
player(1) = player(1) - enemydos
print "you and your oponent attack each other!"
print "you did "; playerdos; " damage!"
print "your enemy did "; enemydos; " damage!"
print "you have " + str$(player(1)) + " health"
print "your enemy has " + str$(enemy(1)) + " health"
rem print in-battle menu with the option to save
input "enter m for in-game menu, otherwise hit enter > ", ingamemenuselection$
if ingamemenuselection$ = "m"
cls
rem print in game menu
print "1: save game"
print "2: exit game"
print "3: continue"
print
input "", ingamemenuselection2
rem outcome due to menu selection
if ingamemenuselection2 =< 1
if file exist(savegamefile$) = 1
delete file savegamefile$
ENDIF
open to write 1, savegamefile$
for x =1 to 2
write string 1, str$(enemy(x))
NEXT x
for x = 1 to 2
write string 1, str$(player(x))
NEXT
close file 1
ENDIF
if ingamemenuselection2 = 2
rem if the player chooses to exit set to no more battles and play menu
battlebegin = 0
menu = 0
ENDIF
ENDIF
wait key
cls
return
loadlast:
if file exist(savegamefile$) = 1
rem open the file to read
open to read 1, savegamefile$
for x = 1 to 4
read string 1, t$ : temparray(x) = val(t$)
NEXT x
rem close and delete the file only if it is stored in game memory
close file 1
delete file savegamefile$
ENDIF
return
its still got a couple of bugs mind you that im working out.
my next question is that i was hoping you could give me an idea of a basic 2d game i could create using just the basics. nothing too fancy just something to help me learn a little bit more.
thank you for your time.