Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Array variable problem

Author
Message
G_Unit
21
Years of Service
User Offline
Joined: 30th Aug 2003
Location: Sacramento, California
Posted: 17th Apr 2004 23:48
I trying to get the feel for darkbasic and its variables and such and have been playing around with some code i found for the site. I am trying to update the array Monster(1) to the screen with the new value after it has been calculated in the label _Att. But everytime i push 1 , the number doesnt change and stays the same. Ive looked around the site for some answers and was unable to find any so if anyone could help it would be greatly appreciated.

HaHaHa, Its G-Unit Baby...
G_Unit
21
Years of Service
User Offline
Joined: 30th Aug 2003
Location: Sacramento, California
Posted: 17th Apr 2004 23:55
Rem Player
Rem 1=Health , 2=Attack , 3=Defense
Dim Player(3)
Dim Monster(3)

Rem Player Info
Player(1)=100
Player(2)=6
Player(3)=10

Rem Monster Info
Monster(1)=100
Monster(2)=3
Monster(3)=5

Rem SetUp Info On Screen
Set Cursor 100,100
Print Player(1)
Set cursor 200,200
Print Monster(1)

Rem Check
Do
If keystate(2)=1
gosub _Att
endif
Loop

Rem Check Hit
If Hit=1
Monster(1)=Monster(1)-Attack
Print Monster(1)
endif

Rem Attack SubRoutine
_Att:
Attack = Rnd(10) + 1
If Player(1)> Attack
Hit = 1
Else
Hit = 0
Endif
Return

Rem Update
Do
sync
loop

Sorry heres the code

HaHaHa, Its G-Unit Baby...
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 18th Apr 2004 00:28
move your "loop" part of the do-loop down to cover the display of the health, at the moment all you do is check for a keypress and update the value, you never actualy do anything to display it since you are stuck in the do-loop and the gosub, just endlessly cycling through them.

Mentor.

PC1: P4 hyperthreading 3ghz, 1gig mem, 2x160gig hd`s, ATI radeon 9800 pro gfx, 6 way surround sound, PC2: AMD 1.2ghz, 512mb ram, FX5200 ultra gfx, stereo 16 bit soundblaster, ups.
G_Unit
21
Years of Service
User Offline
Joined: 30th Aug 2003
Location: Sacramento, California
Posted: 18th Apr 2004 20:12
Thx Mentor for the help , i appreciate it

HaHaHa, Its G-Unit Baby...

Login to post a reply

Server time is: 2024-09-22 06:24:30
Your offset time is: 2024-09-22 06:24:30