Qbasicnews.com
December 15, 2019, 09:29:32 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: read help, will not read,  (Read 1228 times)
TheDarkJay
I hold this place together
*****
Posts: 913



WWW
« on: March 31, 2005, 11:28:31 AM »

Once again i have retreated into the newbie section. I am making a game using data for sprites, when ever i un it though i get a syntax error on read, this never happened when before, but i recently a 31 * 31 building instead of a 10 * 10. what is wrong, here is the code

Code:
DIM grass(1000), grass2(1000), bground(1000), house(1000)
DIM SHARED map(21, 20)
DECLARE SUB battle (lv, presethealth, lvupxp, health, minattack, maxattack, minspell, maxspell, defence, mgdefence, speed, gold, xp, ename$, ehealth, eminattack, emaxattack, edefence, emgdefence, espeed, goldwon, expearned)
DECLARE SUB healandsave (lv, presethealth, lvupxp, health, minattack, maxattack, minspell, maxspell, defence, mgdefence, speed, gold, xp)

SCREEN 12

lv = 1
presethealth = 100
lvupxp = 100
health = presethealth
minattack = 5
maxattack = 10
minspell = 5
maxspell = 10
defence = 10
mgdefence = 10
speed = 10
gold = 100
xp = 0


FOR y = 1 TO 31: FOR x = 1 TO 31: READ h: PSET (x, y), h: NEXT: NEXT

DATA 15,15,15,15,15,15,15,15,15,15,07,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15
DATA 15,15,15,15,15,15,15,15,15,15,07,15,15,15,15,08,08,15,15,15,15,15,15,15,15,15,15,15,15,15,15
DATA 15,15,15,15,15,15,15,15,15,15,07,08,07,07,07,08,08,15,15,15,15,15,15,15,15,15,15,15,15,15,15
DATA 15,15,15,15,15,15,07,07,07,07,08,07,07,07,07,08,08,07,07,07,07,08,15,15,15,15,15,15,15,15,15
DATA 08,08,07,07,07,07,07,07,07,07,07,07,07,07,07,08,08,07,07,07,07,07,07,07,08,07,07,08,15,15,15
DATA 08,01,01,01,08,08,01,08,08,07,07,07,07,07,07,07,07,07,07,08,08,08,01,08,01,08,08,08,15,15,15
DATA 08,01,08,08,08,08,08,01,01,08,01,01,08,08,08,01,01,08,01,08,01,08,01,08,09,08,08,08,15,15,15
DATA 08,08,08,01,08,08,01,01,01,08,08,08,08,08,08,01,01,08,01,08,09,08,01,08,01,08,08,08,15,15,15
DATA 08,01,01,01,08,08,08,01,08,08,08,01,01,01,08,07,01,01,09,08,01,08,01,08,01,08,08,08,15,15,15
DATA 08,01,08,08,08,08,08,01,01,08,01,01,08,08,08,01,01,08,01,08,01,08,01,08,01,08,08,08,15,15,15
DATA 08,08,08,01,08,08,01,01,01,08,08,08,08,08,08,01,01,08,01,08,01,08,01,08,01,08,08,08,15,15,15
DATA 08,01,01,01,08,08,01,08,08,08,01,01,01,08,08,01,01,08,01,08,01,08,01,08,01,08,08,08,15,15,15
DATA 08,01,01,01,08,08,01,08,08,08,01,01,01,08,08,01,01,08,01,08,01,08,01,08,01,08,08,08,15,15,15
DATA 08,01,01,01,08,08,01,08,08,08,01,01,01,08,08,01,01,08,01,08,01,08,07,08,07,07,07,07,08,07,07
DATA 08,01,08,08,08,08,08,01,01,08,01,01,08,08,08,07,07,07,07,07,07,07,07,07,07,07,07,07,07,07,07
DATA 08,01,08,08,08,08,08,01,01,08,01,01,08,08,08,07,07,07,07,07,07,07,07,07,07,07,07,07,07,07,07
DATA 08,08,08,01,08,08,01,01,01,08,08,08,08,08,07,08,08,08,07,07,07,07,07,07,07,07,07,07,07,07,07
DATA 08,01,01,01,08,08,01,08,08,08,01,01,01,08,07,08,08,08,07,07,07,07,07,07,07,07,07,07,07,07,07
DATA 08,08,08,01,08,08,01,01,01,08,08,08,08,08,07,08,08,08,07,07,07,07,07,07,07,07,07,07,07,07,07
DATA 08,08,08,01,08,08,01,01,01,08,08,08,08,08,07,08,08,08,07,07,07,07,07,07,07,07,07,07,07,07,07
DATA 08,01,01,01,08,08,01,08,08,08,01,01,01,08,07,08,08,08,07,07,07,07,07,07,07,07,07,07,07,07,07
DATA 08,01,08,08,08,08,08,01,01,08,01,01,08,08,07,08,08,08,07,07,07,07,07,07,07,07,07,07,07,07,07
DATA 08,08,08,01,08,08,01,01,01,08,08,08,08,08,07,08,08,08,07,07,07,07,07,07,07,07,07,07,07,07,07
DATA 08,01,01,01,08,08,01,08,08,08,01,01,01,08,07,08,08,08,07,07,07,07,07,07,07,07,07,07,07,07,07
DATA 08,01,08,08,08,08,08,01,01,08,01,01,08,08,07,08,08,08,07,07,07,07,07,07,07,07,07,07,07,07,07
DATA 08,08,08,01,08,08,01,01,01,08,08,08,08,08,07,08,08,08,07,07,07,07,07,07,07,07,07,07,07,07,07
DATA 08,01,01,01,08,08,01,08,08,08,01,01,01,08,07,08,08,08,07,07,07,07,07,07,07,07,07,07,07,07,07
DATA 08,01,08,08,08,08,08,01,01,08,01,01,08,08,07,08,08,08,07,07,07,07,07,07,08,06,06,06,06,07,07
DATA 08,08,08,01,08,08,01,01,01,08,08,08,08,08,07,08,08,08,07,07,06,06,06,06,08,08,08,06,06,07,07
DATA 15,15,15,08,08,08,08,08,08,08,1,1,1,08,08,07,08,08,08,07,07,06,06,06,06,08,06,06,06,15,15,15
DATA 15,15,15,15,15,15,15,15,15,15,08,08,08,08,07,08,08,08,07,07,06,06,08,15,15,15,15,15,15,15,15                                                                                                  

GET (1, 1)-(31, 31), house



FOR y = 1 TO 10
FOR x = 1 TO 10
READ a
PSET (x, y), a
NEXT
NEXT

DATA 02,10,02,02,02,02,10,02,02,02
DATA 02,02,02,02,10,02,02,02,02,10
DATA 02,02,10,02,02,02,02,02,02,02
DATA 10,02,02,02,02,10,02,02,10,02
DATA 02,02,10,02,02,02,02,02,02,02
DATA 10,02,02,02,10,02,02,10,02,02
DATA 02,10,02,02,02,02,02,02,02,10
DATA 02,02,02,02,10,02,02,02,02,02
DATA 02,10,02,02,02,02,10,02,10,02
DATA 02,02,02,10,02,02,02,02,02,02

GET (1, 1)-(10, 10), grass

CLS

FOR y = 1 TO 10
FOR x = 1 TO 10
READ c
PSET (x, y), c
NEXT
NEXT

DATA 02,02,10,02,02,10,02,02,10,02
DATA 10,02,02,02,02,02,02,02,02,02
DATA 02,02,10,02,10,02,10,02,10,02
DATA 10,02,02,02,02,02,02,02,02,02
DATA 02,02,10,02,02,10,02,10,02,02
DATA 10,02,02,02,02,02,02,02,02,10
DATA 02,02,10,02,10,02,10,02,02,02
DATA 02,02,02,02,02,02,02,02,10,02
DATA 02,10,02,02,10,02,10,02,02,02
DATA 02,02,02,10,02,02,02,02,02,10

GET (1, 1)-(10, 10), grass2


CLS

FOR my = 0 TO 19
FOR mx = 0 TO 20
READ map(mx, my)
NEXT
NEXT

DATA 3,1,2,1,2,2,2,1,1,2,1,2,1,1,2,2,2,2,2,2
DATA 2,2,1,2,1,2,1,2,1,1,1,2,2,2,1,1,1,1,1,1
DATA 1,1,1,1,2,2,2,1,1,2,1,2,1,1,1,2,2,2,2,2
DATA 2,2,2,2,2,2,1,1,2,1,1,1,1,2,2,1,1,1,2,1
DATA 1,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2
DATA 1,1,1,1,2,2,2,1,1,2,2,2,1,1,2,2,2,2,2,2
DATA 2,2,1,2,1,2,1,2,1,1,2,2,2,2,1,1,1,1,1,1
DATA 1,1,1,1,2,2,2,1,1,2,2,2,1,1,2,2,2,2,2,2
DATA 2,2,2,2,2,2,1,1,2,1,1,1,1,2,2,1,1,1,2,1
DATA 1,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2
DATA 2,2,1,2,1,2,1,2,1,1,2,2,2,2,1,1,1,1,1,1
DATA 1,1,1,1,2,2,2,1,1,2,2,2,1,1,2,1,2,2,2,2
DATA 2,2,2,2,2,2,1,1,2,1,1,1,1,2,2,1,1,1,2,1
DATA 1,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2
DATA 1,1,1,1,2,2,2,1,1,1,2,2,1,1,2,1,2,2,2,2
DATA 1,1,1,1,2,2,2,1,1,2,2,2,1,1,2,2,2,2,2,2
DATA 2,2,1,2,1,2,1,2,1,1,2,2,2,2,1,1,1,1,1,1
DATA 1,1,1,1,2,2,2,2,2,2,2,2,1,1,2,2,2,2,2,2
DATA 2,2,2,2,2,2,1,1,2,1,1,1,1,2,2,1,1,1,2,1
DATA 1,2,2,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,2,2
DATA 2,2,2,1,1,1,2,2,2,1,1,2,1,2,2,2,1,2,1,2

nx = 150
ny = 150
 x = 100
 y = 100

CLS

re:
FOR my = 0 TO 19
FOR mx = 0 TO 20
IF map(mx, my) = 1 THEN PUT (mx * 10, my * 10), grass
IF map(mx, my) = 2 THEN PUT (mx * 10, my * 10), grass2
IF map(mx, my) = 3 THEN PUT (mx * 10, my * 10), house
NEXT
NEXT

LOCATE 20, 20: PRINT "Press [esc] to end"

GET (x, y)-(x + 10, y + 10), bground
LINE (x, y)-(x + 10, y + 10), 1, BF

DO
key$ = INKEY$

SELECT CASE key$

CASE CHR$(0) + CHR$(75)
IF x > 0 THEN
oldx = x
oldy = y
x = x - 10
LINE (oldx, oldy)-(oldx + 10, oldy + 10), 0, BF
PUT (oldx, oldy), bground
GET (x, y)-(x + 10, y + 10), bground
LINE (x, y)-(x + 10, y + 10), 1, BF
END IF

CASE CHR$(0) + CHR$(77)
IF x < 200 THEN
oldx = x
oldy = y
x = x + 10
LINE (oldx, oldy)-(oldx + 10, oldy + 10), 0, BF
PUT (oldx, oldy), bground
GET (x, y)-(x + 10, y + 10), bground
LINE (x, y)-(x + 10, y + 10), 1, BF
END IF

CASE CHR$(0) + "H"
IF y > 0 THEN
oldx = x
oldy = y
y = y - 10
LINE (oldx, oldy)-(oldx + 10, oldy + 10), 0, BF
PUT (oldx, oldy), bground
GET (x, y)-(x + 10, y + 10), bground
LINE (x, y)-(x + 10, y + 10), 1, BF
END IF

CASE CHR$(0) + CHR$(80)
IF y < 190 THEN
oldx = x
oldy = y
y = y + 10
LINE (oldx, oldy)-(oldx + 10, oldy + 10), 0, BF
PUT (oldx, oldy), bground
GET (x, y)-(x + 10, y + 10), bground
LINE (x, y)-(x + 10, y + 10), 1, BF
END IF

CASE "t"
'testing map redraw and battle

IF lv = 1 THEN
 ename$ = "FlyHunt"
 ehealth = 50
 eminattack = 10
 emaxattack = 10
 edefence = 1
 emgdefence = 1
 espeed = 1
 goldwon = 100
 expearned = 80
END IF

IF lv = 2 THEN

 ename$ = "Seek And Destroyer"
 ehealth = 100
 eminattack = 15
 emaxattack = 20
 edefence = 5
 emgdefence = 4
 espeed = 6
 goldwon = 100
 expearned = 100
END IF

IF lv = 3 THEN

 ename$ = "Hunter Killious"
 ehealth = 150
 eminattack = 20
 emaxattack = 25
 edefence = 5
 emgdefence = 100
 espeed = 10
 goldwon = 10000
 expearned = 200
END IF

IF lv = 4 THEN

 ename$ = "Removoid"
 ehealth = 200
 eminattack = 30
 emaxattack = 35
 edefence = 10
 emgdefence = 10
 espeed = 20
 goldwon = 100
 expearned = 100
 END IF

IF lv >= 5 THEN

 ename$ = "DarkAbyss"
 ehealth = 300
 eminattack = 20
 emaxattack = 45
 edefence = 0
 emgdefence = 15
 espeed = 50
 goldwon = 500
 expearned = 500
 END IF


CALL battle(lv, presethealth, lvupxp, health, minattack, maxattack, minspell, maxspell, defence, mgdefence, speed, gold, xp, ename$, ehealth, eminattack, emaxattack, edefence, emgdefence, espeed, goldwon, expearned)
CLS
GOTO re

CASE CHR$(27)
END

CASE " "
IF x = nx + 10 AND y = ny THEN
LOCATE 15, 20: PRINT "ROAR"

DO
key$ = INKEY$
IF key$ = CHR$(27) THEN END
LOOP UNTIL key$ = " "
LINE (150, 220)-(400, 300), 0, BF


 ename$ = "Black Beast"
 ehealth = 1000
 eminattack = 50
 emaxattack = 100
 edefence = 1000
 emgdefence = 1000
 espeed = 1000
 goldwon = 10000
 expearned = 900000

CALL battle(lv, presethealth, lvupxp, health, minattack, maxattack, minspell, maxspell, defence, mgdefence, speed, gold, xp, ename$, ehealth, eminattack, emaxattack, edefence, emgdefence, espeed, goldwon, expearned)
CLS
GOTO re

END IF

END SELECT

WAIT &H3DA, 8
LINE (nx, ny)-(nx + 10, ny + 10), 5, BF
LINE (nx + 10, ny)-(nx + 10, ny + 10)

IF x = 0 AND y = 0 THEN
y = 20
GET (x, y)-(x + 10, y + 10), bground
CLS
CALL healandsave(lv, presethealth, lvupxp, health, minattack, maxattack, minspell, maxspell, defence, mgdefence, speed, gold, xp)
CLS
GOTO re
END IF
LOOP

SUB battle (lv, presethealth, lvupxp, health, minattack, maxattack, minspell, maxspell, defence, mgdefence, speed, gold, xp, ename$, ehealth, eminattack, emaxattack, edefence, emgdefence, espeed, goldwon, expearned)

CLS
'the battle starts
PRINT "         BATTLE"
PRINT "The enemy is a "; ename$; "."


IF espeed > speed THEN GOTO eattack

mcattack: PRINT " Your current health is "; health; "."
PRINT "Your enemies health is "; ehealth; "."

IF health = 0 THEN GOTO dead
IF health < 0 THEN GOTO dead
PRINT "What do you want to do?"
PRINT "(m)elee"
PRINT "(s)pell"

DO
key$ = INKEY$
IF key$ = LCASE$("m") THEN GOTO melee
IF key$ = LCASE$("s") THEN GOTO spell
LOOP

melee: CLS
damage = INT(RND * maxattack) + minattack
damage = damage - edefence
IF damage < 0 THEN damage = 0
PRINT "You did "; damage; "damage."
ehealth = ehealth - damage
IF ehealth = 0 THEN GOTO win1
IF ehealth < 0 THEN GOTO win1
GOTO eattack

spell: CLS
damage = INT(RND * maxspell) + minspell
damage = damage - emgdefence
IF damage < 0 THEN damage = 0
PRINT "You did "; damage; "."
ehealth = ehealth - damage
IF ehealth = 0 THEN GOTO win1
IF ehealth < 0 THEN GOTO win1

eattack: damage = INT(RND * emaxattack) + eminattack
damage = damage - defence
IF damage < 0 THEN damage = 0
PRINT "You took "; damage; "damage."
health = health - damage
IF health = 0 THEN GOTO dead
IF health < 0 THEN GOTO dead
GOTO mcattack

dead:
COLOR 5
CLS
PRINT "You died"
LOCATE 20, 20: PRINT "Press anykey to close this program"
DO
LOOP WHILE INKEY$ = ""
END

win1: PRINT "you won"
PRINT "You got "; expearned; " exp"
xp = expearned + xp
IF xp >= lvupxp THEN GOTO lvup1
winner1: PRINT "You need "; lvupxp - xp; " more exp to lv up"
PRINT "You got "; goldwon; " gold"
gold = gold + goldwon
PRINT "Your total gold is "; gold; " gold."
PRINT "Press any key to continue"
DO WHILE INKEY$ = ""
LOOP
EXIT SUB

lvup1: PRINT "Press any key to continue"
DO WHILE INKEY$ = ""
LOOP
CLS
PRINT "Congratulations, you leveled up"
presethealth = presethealth + 50
lv = lv + 1
lvupxp = lvupxp * 2
health = presethealth
minattack = minattack + 1
maxattack = maxattack + 1
minspell = minspell + 1
maxspell = maxspell + 1
defence = defence + 2
mgdefence = mgdefence + 2
speed = speed + 1

PRINT "You are now level "; lv; "."
PRINT "Your health is now "; health; "."
PRINT "Your minattack is now "; minattack; "."
PRINT "Your maxattack is now "; maxattack; "."
PRINT "Your minspell is now "; minspell; "."
PRINT "Your maxspell is now "; maxspell; "."
PRINT "Your defence is now "; defence; "."
PRINT "Your speed is now "; speed; "."
PRINT "Press any key to continue"

DO WHILE INKEY$ = ""
LOOP

CLS
GOTO winner1

END SUB

SUB healandsave (lv, presethealth, lvupxp, health, minattack, maxattack, minspell, maxspell, defence, mgdefence, speed, gold, xp)
CLS
PRINT "It will cost 10 gold to heal you and save the game"
PRINT "do you wish to save and recover your wounds?"
PRINT
IF gold < 10 THEN EXIT SUB

COLOR 12
PRINT "What do you want to do"
PRINT
PRINT "1) Save and heal"
PRINT "2) Heal without saving"
PRINT "3) Forget the whole thing and return to the field"
COLOR 15

DO
key$ = INKEY$

SELECT CASE key$

CASE "1"

OPEN "Forest.FSF" FOR OUTPUT AS #1
PRINT #1, presethealth
PRINT #1, lvupxp
PRINT #1, health
PRINT #1, minattack
PRINT #1, maxattack
PRINT #1, minspell
PRINT #1, maxspell
PRINT #1, defence
PRINT #1, mgdefence
PRINT #1, speed
PRINT #1, gold
PRINT #1, xp
CLOSE #1
health = presethealth
gold = gold - 10
EXIT SUB

CASE "2"
health = presethealth
gold = gold - 10
EXIT SUB

CASE "3"
EXIT SUB

CASE CHR$(27)
END

END SELECT

LOOP

COLOR 15

END SUB


please ignore my noob programming and the fact that the house doesnt fit on the map.
Logged

url=http://www.sloganizer.net/en/][/url]
Mitth'raw'nuruodo
Ancient Guru
****
Posts: 515



WWW
« Reply #1 on: March 31, 2005, 06:22:16 PM »

Well, I guess I'll leave your noob programming alone for now...lol :lol:

here:
before this line:
FOR y = 1 TO 31: FOR x = 1 TO 31: READ h: PSET (x, y), h: NEXT: NEXT

put:
RESTORE Yo
-------------------------------
before this line:
DATA 15,15,15,15,15,15,15,15,15,15,07,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15

Put:
Yo:
--------------------------
before this line:
FOR y = 1 TO 10
FOR x = 1 TO 10
READ a
PSET (x, y), a
NEXT
NEXT

put:
RESTORE Yo1
-------------------------------
before this line:

DATA 02,10,02,02,02,02,10,02,02,02
DATA 02,02,02,02,10,02,02,02,02,10

Put:
Yo1:
--------------------------

That worked for me!
Logged

i]"But...it was so beautifully done"[/i]
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!