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 / Looping problem

Author
Message
Fallout3fan
15
Years of Service
User Offline
Joined: 9th May 2009
Location:
Posted: 29th May 2012 06:32
This time I think loop created a problem in my turn based combat. Is there some way you guys can fix it?


_!!!!_
,0~U -Well I do say, its been quite a fancy forum for
__-____TheZachadoodle.________________________________
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 29th May 2012 11:20
I was able to get a somewhat turn-based game going just by placing this:

status = 0

to just above the if statement it's in ending up with this in the players_turn subroutine:



Full:


nonZero
13
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 29th May 2012 11:21 Edited at: 29th May 2012 11:50
Tip: It's much easier to manage text by converting it to single case, ie:
Quote: "
if Battle$="A" and status=0
status=1
endif
if Battle$="a" and status=0
status=1
endif
endif
if Battle$<>"A" and Battle$<>"a"
print "Invalid, please try again."
endif
"

Can be simplified to:

As for giving the player a chance to stop and make a decision, change your code structure and use a wait system (gives the player n seconds to press a key before the computer goes again) or simply add more options to your INPUT such as "B: Run away scared", "C: Timeout!", "D: Eat cake", etc. Also, your status flag is being poorly handled which accounts for the infinite looping (It's skipping the second player input) and your code's a little bit of a mess (Indenting prevents you loosing track of nests) and I noticed a double ENDIF when I ran your code. Hope this gets you started.

[EDIT]Ah, Hodgey, ya beat me to it at < 1 minute apart. Nice to see you back btw [/EDIT]

Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 29th May 2012 13:18
Quote: " Nice to see you back btw "

Thanks nonZero! I've been hanging out on the AppGameKit boards but decided to visit the newcomer's corner for a little break. It's been a while since I've fired up DBP and your sharp skills haven't left me much to do. Keep up the good work mate and I might pop in now and then.

Fallout3fan
15
Years of Service
User Offline
Joined: 9th May 2009
Location:
Posted: 30th May 2012 18:45
Thank you guys for your support.

I was kinda of a noob at using Dark Basic and you guys stepped in and helped. Thank you so much and I used the code.

_!!!!_
,0~U -Well I do say, its been quite a fancy forum for
__-____TheZachadoodle.________________________________

Login to post a reply

Server time is: 2024-11-23 21:08:53
Your offset time is: 2024-11-23 21:08:53