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 / Evaluating variables to other variables in a Case statement...

Author
Message
AlexB
21
Years of Service
User Offline
Joined: 30th Oct 2003
Location:
Posted: 31st Oct 2003 17:10
Ok, so how exactly do you guys tend to evaluate user input in your games?

What I've set up is a kind of global collection of integers, one for each possible user action in the game (a basic 2d side scroller). E.G:

MenUp = 1
MenUpAndFire = 2
MenUpLeftAndFire = 3
MenLeft = 4
MenLeftAndFire = 5
etc etc etc...

I have a function that evaluates the KeyState of each available key, and returns one of these integer values depending on which key or combination of keys is being pressed. However, when coming to do all the sprite stuff, I can't use a case statement to evaluate to my integer variables. DB fails to compile with a 'CASE Needs a literal parameter' error.

What I'm trying to do is like this:

iValue = 1

Select iValue
Case MenUp
`Process Up Move
EndCase
Case MenUpAndFire
`Process Up and Fire move
EndCase
EndSelect

It's really only so that I can trace all user action (as well as everything else in the game) by name rather than remembering by number. (does anyone else do this? If not how do you keep track of stuff?) I had a hard enough time splitting the KeyState checks into 16 if statements because DB couldn't manage nesting more than three deep, am I gonna have to do the same here? Any help would be really greatly appreciated.

thanks a lot!
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 1st Nov 2003 23:58
I've fallen foul of this too. I'm sure it used to work in DBC, but not in DB Pro.

BatVink (formerly StevieVee)
http://facepaint.me.uk/catalog/default.php
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 2nd Nov 2003 00:02
are you saying the problem is it is not recognizing Case MenUp as 1?
If so maybe the case statement needs a literal instead of an expression.

-RUST-

Login to post a reply

Server time is: 2024-11-10 22:53:32
Your offset time is: 2024-11-10 22:53:32