Page 1 of 1
Blitz Basic problems and discussion.
Posted: Fri Jan 02, 2009 11:13 pm
by spum
ok so i was advised to make this topic so that i can solve problems and get my problems solved. so here is the first problem.
i would like to know with the following code how i can make it to where the player can only go one direction at a time and to have to diagonal directions. because its just to glitchey when it comes to collision so here is the code
ok so dir is the variable that controls what frames need to be animated during a certain direction movement so if dir = D_UP then that means the player is moving up and to draw the up frames. btw dir is of type const
actual movent code
Code: Select all
If KeyDown(200) Then playery = playery - 5 : dir = D_UP
If KeyDown(208) Then playery = playery + 5 : dir = D_DOWN
If KeyDown(203) Then playerx = playerx - 5 : dir = D_LEFT
If KeyDown(205) Then playerx = playerx + 5 : dir = D_RIGHT
so there it is, if u can help me out then i appreciate it 100%
and if you need help with any code problems i'll do my best to help with yours as well
Re: Blitz Basic problems and discussion.
Posted: Fri Jan 02, 2009 11:42 pm
by eatcomics
Ha I had the same problem, I just made it so if the player is hitting two buttons at once like so:
Code: Select all
If keyhit(LEFT) And keyhit(UP) player\direction = 1 ;If player is hitting up and left make the player just go up
So instead of playerx = x + x
I have a direction if it equals one the player is going up 2 down 3 left 4 right so on so fourth.
If you need a better explanation just say so
Edit: The direction sets the player's x and y, and it does the animation...
Re: Blitz Basic problems and discussion.
Posted: Fri Jan 02, 2009 11:50 pm
by eatcomics
I think I read your post wrong, you want up, down, left, right, and going up and left, or up and right, and you want an animation for that... Just make a new direction like D_UPRIGHT or D_DOWNLEFT so you would have this
Code: Select all
If keydown(LEFT) and keydown(UP)
playerx = playerx + 5
playery = playery - 5
playerdirection = D_UP_LEFT ;Then draw the proper animation play
endif
At least I think that should solve your problem.
I'm not exactly sure what you want, if this isn't what you want (and the other post isn't either) then tell me exactly what you want
Re: Blitz Basic problems and discussion.
Posted: Sat Jan 03, 2009 12:02 am
by spum
no i wanted not to have upright etc i just wanted 4 directions up,down,left,right, and i am having trouble your code snippet work
Re: Blitz Basic problems and discussion.
Posted: Sat Jan 03, 2009 1:41 am
by eatcomics
so you want 4 directions, just make sure if two buttons are pressed at once to just make the player go in one direction I can help further if you pmed me with your code, I think you have it layed out different then me, that is where the problem is:)
Re: Blitz Basic problems and discussion.
Posted: Sat Jan 03, 2009 2:09 am
by spum
its ok i got it to work, and it works great no more glitches yeah.!!!
Re: Blitz Basic problems and discussion.
Posted: Sat Jan 03, 2009 3:01 am
by eatcomics
That's good to hear...I myself am working on a post zombie apocalyptic text based rpg in c++ and don't know where to go next....
although I doubt the project will ever be done, it gets me away from my blitz game
Re: Blitz Basic problems and discussion.
Posted: Sat Jan 03, 2009 6:18 am
by ismetteren
I dont know blitz, but i guess that it also has an else if statement. Just make it:
if keydown(UP) goUp();
else if keydown(DOWN) goDown();
else if ....
else if ....
then it will stop checking when it finds a key that is down, and therefor only go in one direction per frame. The problem, if you think it is a problem, is that the buttons has some kind of heiracy. if all arrow keys are down, then the charactor will go up, because up is the first that get chekked, and so on.
Re: Blitz Basic problems and discussion.
Posted: Sat Jan 03, 2009 10:23 am
by spum
yea i got it and it works perfectly and has no glitches so i am good. so the next topic of this thread is on how to create GUI's for your programs . so if u know anything about GUI and how to make it work with blitz basic then feel free to post a tutorial or a site,!!!!!!
Re: Blitz Basic problems and discussion.
Posted: Sat Jan 03, 2009 5:54 pm
by eatcomics
yep sure does have an else if, does c++, I can't remeber... well you don't have to tell me I can look it up later I guess.
I myself have been looking at gui, but not actually used it so I don't know if I will be any help.... although, I may use it later for my rts.... maybe.... most likely... so many...'s oh well...