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.

DarkBASIC Discussion / Problem with an Array and Input

Author
Message
flock
19
Years of Service
User Offline
Joined: 10th Mar 2006
Location: Earth
Posted: 27th Mar 2006 16:24
Okay, I've got something to share. I've been working on a 2D game for quite some time before I've decided to start making my own DBC-compatible level editor. It'll be called Revelation2D and it will be released into the public after I've created my game.

Now, I've been writing the main program and a some functions in a seperate file and I've come across a probably simple problem. When the user has asked to make a map from the menu it will prompt R2D to ask which size of map he wants. Now, this is fairly simple code and I understand that; I'm most certainly not the best programmer out there even though DBC is simple compared to Java (which I'm okay at).

The code doesn't work the way I want it because I've tried to create it so the the user hits the return key to go to the next string in my baseT$ array (Base Tiles) and then display it. Then after the user has selected the tile scale I'd want him or her to only have to enter to execute with the selected baseT$. I don't need help going further into the program, just this little selection subroutine.




hide sprite 1
cls
sync on
do

dim baseT$(2)
baseT$(1)="30 x 30"
baseT$(2)="40 x 60"

setT=1
if returnkey()>0 then inc setT,1:wait 200
ink rgb(210,210,210),rgb(255,255,255)
box 190,190,415,230
ink rgb(0,0,0),rgb(255,255,255)
set cursor 200,200
print "Set Tile Setup ",baseT$(setT)

sync
loop




How would I make it so that the user will hit the return key once and the setT will inc without having to hold down the return key? Also know that this will not be the entire list of baseT$ options combined upon release.

Note: I've added a gray box to the background only so the screen will refresh what has been printed.

I've also had the idea of using the R2D.ini file I've already created for the editor to store the different sizes with baseT$ as integers. Then when the user has a baseT$ selected the editor will call on the .ini variables already typed in to help set the tile matrix. Ugh...


Thanks
Pincho Paxton
22
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 27th Mar 2006 23:48
Don't know what you mean. Sounds like you need a loop after the return key, and maybe you are saying that the return key is also in a loop as well. You only have a few loops to choose from..

For Next
Repeat Until
While Endwhile

But the way you have explained it is hard to understand.

Login to post a reply

Server time is: 2025-05-23 19:13:48
Your offset time is: 2025-05-23 19:13:48