Skip to main content
gamedev.net
🔒 Locked

Blitz Basic Problem

Started by TheCrow 3 replies 950+ views
Original Post
TheCrow
TheCrow
Hey, I'm currently working on a BlitzBasic (because its simple and easy to use) Top-Down 2D RPG. While I was writing the code to stop when you hit a solid object I ran into a problem. The Langauge has problems using any combination of more than 3 if.. else.. elseif... clauses. Now my problem is I need to check all 4 sides for the collision, but I can't use 4 if clauses. I thought that it might handle the Switch statement easier, however I would need it to return a number to tell me which side i have hit (which in turn makes me write 4 if statements). What I have been trying looks something like this. if (player\x <= npc\x) then player\x = player\x else... This is setup in a function that is only called when there has been a collision. And works just fine with two or three of these clauses but when I put in the fourth that looks nearly the same, the language skips a few. Any suggestions of some alternative routes around using the if statements?
oliii
oliii
If you use that many ifs, then yeah, build up a switch/case statement, or avoid the if/else all together.

Are you sure it's not a bug in your algo instead, that makes it look like it's not doing what it's suppose to?

What are you trying to do exactly? Surely there is a better solution.
Everything is better with Metal.
tonyg
tonyg
I've not had issues with multiple if/else/elseif or whatever with BlitzBasic.
What version are you using?
Anyway, you can use Case statements or 4 ifs and exit the check when one fires.
CzarKirk
CzarKirk
Post the entire section of code, as I have never had problems with them before. Shouldn't it be, if elseif elseif rather than if else elseif? Also it's called select in BlitzBasic not switch. How could you try it if you don't even know what the command is called?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.