Blitz Basic problems and discussion.

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
spum
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 39
Joined: Tue Dec 23, 2008 10:41 pm

Blitz Basic problems and discussion.

Post 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
User avatar
eatcomics
ES Beta Backer
ES Beta Backer
Posts: 2528
Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois

Re: Blitz Basic problems and discussion.

Post 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...
Last edited by eatcomics on Fri Jan 02, 2009 11:51 pm, edited 1 time in total.
Image
User avatar
eatcomics
ES Beta Backer
ES Beta Backer
Posts: 2528
Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois

Re: Blitz Basic problems and discussion.

Post 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 :mrgreen:
Image
spum
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 39
Joined: Tue Dec 23, 2008 10:41 pm

Re: Blitz Basic problems and discussion.

Post 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
User avatar
eatcomics
ES Beta Backer
ES Beta Backer
Posts: 2528
Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois

Re: Blitz Basic problems and discussion.

Post 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:)
Image
spum
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 39
Joined: Tue Dec 23, 2008 10:41 pm

Re: Blitz Basic problems and discussion.

Post by spum »

its ok i got it to work, and it works great no more glitches yeah.!!!
User avatar
eatcomics
ES Beta Backer
ES Beta Backer
Posts: 2528
Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois

Re: Blitz Basic problems and discussion.

Post 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 ;)
Image
User avatar
ismetteren
Chaos Rift Junior
Chaos Rift Junior
Posts: 276
Joined: Mon Jul 21, 2008 4:13 pm

Re: Blitz Basic problems and discussion.

Post 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.
Image ImageImage Image
spum
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 39
Joined: Tue Dec 23, 2008 10:41 pm

Re: Blitz Basic problems and discussion.

Post 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,!!!!!!
User avatar
eatcomics
ES Beta Backer
ES Beta Backer
Posts: 2528
Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois

Re: Blitz Basic problems and discussion.

Post 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...
Image
Post Reply