Here is my rpg game. The code for loading the 2D map won't load the map.
I've tried to change the arraay but that doesn't work.
Here is the code. The map is at the bottem.
Turing: |
%Cutthroat RPG! Started Wednesday, April 22.%
import GUI
View.Set ("graphics:600;400,nobuttonbar")
var name : string
var hp : real
var race : string
var power : int
var money : real := 0
var level: real:= 1
var weapon : string
var armour : string
var experience : real:= 0
var nextlevel : real
GUI.SetBackgroundColour (red)
procedure Start
GUI.Quit
end Start
procedure Instructions
end Instructions
procedure Load
end Load
var b1 := GUI.CreateButton (10, 250, 100, "Start Game", Start )
var b2 := GUI.CreateButton (130, 200, 100, "Instructions", Instructions )
var b3 := GUI.CreateButton (250, 250, 100, "Load Game", Load )
loop
exit when GUI.ProcessEvent
end loop
cls
proc Create_Character
cls
put "What is your characters name?"
get name
cls
loop
cls
put "Enter your Race."
put "Human - Can easily change its class."
put "Elf - They are known for their poetry, song, and magical arts. They also show great skil with weapons, and strategy."
put "Dwarf - They are known for their skill in warefare, their ability to withstand physical and nagical punishment, and their hard work."
put "Gnome - They are smaller than Dwaves, and make good alchenists, and technicians."
put "Halfling - They are clever, capable, and resouceful suvivers."
put "Half Elf - They get curiosity, and ambition from their human parent, and the love of poetry and song from their elf parent."
put "Alien - They are skilled in magic. They use very powerful magic that is too complicated for even the most powerful wizards to learn."
put "Half Orc - Half orc, half human. They like fighting more than argueing."
put "Demon - They don't have a living body, and are more ghost like, than human like."
get race
exit when race = "Human" or race = "Elf" or
race = "Dwarf" or race = "Gnome" or race = "Halfling" or
race = "Half Elf" or race = "Alien" or race = "Half Orc" or
race = "Demon"
end loop
cls
if race = "Human" then
hp: = 50
power := 7
level := 1
experience := 0
money := 500
end if
if race = "Elf" then
hp: = 50
power := 7
level := 1
experience := 0
money := 500
end if
if race = "Dwarf" then
hp: = 50
power := 7
level := 1
experience := 0
money := 500
end if
if race = "Gnome" then
hp: = 50
power := 7
level := 1
experience := 0
money := 500
end if
if race = "Halfling" then
hp: = 50
power := 7
level := 1
experience := 0
money := 500
end if
if race = "Half Elf" then
hp: = 50
power := 7
level := 1
experience := 0
money := 500
end if
if race = "Alien" then
hp: = 50
power := 7
level := 1
experience := 0
money := 500
end if
if race = "Half Orc" then
hp: = 50
power := 7
level := 1
experience := 0
money := 500
end if
if race= "Demon" then
hp: = 50
power := 7
level := 1
experience := 0
money := 500
end if
put "Character Name: ", name
put "Level: ", level
put "Race: ", race
put "hp: ",hp
put "power: ", power
put "Experience points: ", experience
put "money: ", money
delay (5000) %This delays the program to give you enough time to read your stats.%
end Create_Character
Create_Character
View.Set ("graphics:600;600,offscreenonly")
var tiles : array 0 .. 72, 0 .. 14 of int
var FileName : string := "map.txt"
var FileNo : int
open : FileNo, FileName, get
for decreasing y : 14 .. 0 % for every y
for x : 0 .. 72 %for every x
get : FileNo, tiles (x, y ) %get the tile type at (x,y)
end for
end for
close (FileNo )
procedure reDraw
for x : 0 .. 72
for y : 0 .. 14
if tiles (x, y ) = 1 then
Draw.FillBox (x * 10, y * 10, x * 10 + 10, y * 10 + 10, red) % the +10 is there because each tile is 10 by 10
else
Draw.FillBox (x * 10, y * 10, x * 10 + 10, y * 10 + 10, black)
end if
end for
end for
end reDraw
var key : array char of boolean
var px, py : int := 1 % we start off at grid 1,1
loop
reDraw
Input.KeyDown (key )
if key ('a') and tiles (px - 1, py ) = 0 then
px - = 1
end if
if key ('d') and tiles (px + 1, py ) = 0 then
px + = 1
end if
if key ('s') and tiles (px, py - 1) = 0 then
py - = 1
end if
if key ('w') and tiles (px, py + 1) = 0 then
py + = 1
end if
Draw.FillBox (px * 10, py * 10, px * 10 + 10, py * 10 + 10, yellow)
View.Update
delay (50)
end loop |
Mod Edit: Fixed syntax tags |