Computer Science Canada more than one movement at the same time |
Author: | (O_o) [ Fri Jan 13, 2006 5:31 pm ] |
Post subject: | more than one movement at the same time |
hi i'm trying to make a game where i have a box and i can move it with the arrow keys, and also want to move circles across the screen at the same time. when ever i try to do it, only the circles move. I was wonder if someone could explain to me how to do both at the same time. |
Author: | (O_o) [ Fri Jan 13, 2006 5:42 pm ] | ||
Post subject: | |||
sorry for the double post but if you don't want to download the program here it is
|
Author: | iker [ Fri Jan 13, 2006 5:58 pm ] | ||||
Post subject: | |||||
instead of having all of the directions in one if statement..
try puting them in separate if statements, opposite directions such as up and down can be in the same one..
hope that helps |
Author: | (O_o) [ Fri Jan 13, 2006 6:26 pm ] | ||
Post subject: | |||
thanks for the tip i treid it but it didn't work i can move the ship until add the asteroids, then it i cant move it anymore. so if i take out this part:
and try to move it works so i only can't move when this part comes in |
Author: | Tony [ Fri Jan 13, 2006 7:08 pm ] |
Post subject: | |
that is because you have a bunch of loops with delays in them. It takes quite a while for those loops to finish, and you're not checking for any input while inside the loops. no input -- no movement |
Author: | (O_o) [ Fri Jan 13, 2006 7:44 pm ] |
Post subject: | |
oooo i get what you mean so you're saying that i need to get the program to check for inputs while the asteroids fall. hmmm how would i do that though? |
Author: | Tony [ Fri Jan 13, 2006 8:31 pm ] | ||
Post subject: | |||
step procedures
currently you have your loops set up so that an asteroid would move from beginning to end before letting go of the controls. Try to figure out how to let the asteroid move just 1 step, let go of the controls, and resume from where it left of next time ![]() |
Author: | (O_o) [ Fri Jan 13, 2006 8:46 pm ] |
Post subject: | |
i'm not sure of what you saying.... what do you mean by letting go of the controls? do you mean that i should get the program to check for inputs constantly before each move of the asteroid? |
Author: | Tony [ Fri Jan 13, 2006 9:14 pm ] |
Post subject: | |
(O_o) wrote: do you mean that i should get the program to check for inputs constantly before each move of the asteroid?
not only check, but also process and move the user accordingly |
Author: | (O_o) [ Fri Jan 13, 2006 9:30 pm ] | ||
Post subject: | |||
so do you mean somthing like this?
|
Author: | Tony [ Fri Jan 13, 2006 9:50 pm ] |
Post subject: | |
not quite your asteroid will not move unless UP_ARROW is pressed ![]() try to separate everything into procedures |
Author: | (O_o) [ Sat Jan 14, 2006 12:03 pm ] |
Post subject: | |
example? |
Author: | iker [ Sat Jan 14, 2006 3:12 pm ] | ||
Post subject: | |||
heres an example
|
Author: | (O_o) [ Sun Jan 15, 2006 11:41 am ] |
Post subject: | |
wow.. it worked! thanks alot! but, there were two problems..... one being that as the asteroids come down they flash...but i'm not sure if that's fixable... two that the collision wouldn't work. the bulletjust goes through the asteriod... |
Author: | Cervantes [ Sun Jan 15, 2006 11:56 am ] |
Post subject: | |
Use View.Update. http://www.compsci.ca/v2/viewtopic.php?t=3077 http://www.compsci.ca/v2/viewtopic.php?t=193 |
Author: | (O_o) [ Sun Jan 15, 2006 10:33 pm ] | ||||
Post subject: | |||||
wow, thanks Cervantes but i still can't get the asteroid to disappear after it gets shot. so far i have this thanks to you guys
but when i try to do a collision thing, it never works for example i tried somthing like this:
and it didn't work. |
Author: | Martin [ Sun Jan 15, 2006 10:50 pm ] |
Post subject: | |
Trace through the program and see what happens. You are clearing the screen, but the variable still exists. So on one frame, it detects that the asteroid is hitting and then clears the screen. The next frame though it draws everything again. Not pertaining to your actual problem, but learn how to use arrays! http://www.compsci.ca/v2/viewtopic.php?t=1117 http://www.compsci.ca/v2/viewtopic.php?t=366 |
Author: | Bored [ Mon Jan 16, 2006 4:13 pm ] |
Post subject: | |
What you'll want to do is use a boolean variable (in case you didn't know it's a variable that can contain either true or false) called let's say hasHit that is true if the asteroid has hit the player and false if it hasn't. When the player hits the asteroid you set hasHit to true. Then have it so the asteroid is only draw when hasHit is false. You'll need to do this for all of your asteroids, if you take martins advice and learn to use array you can have an array of boolean values and use a for statement instead of repeating your code 10 times. |
Author: | codemage [ Tue Jan 17, 2006 1:13 pm ] |
Post subject: | |
ha**censored**? ![]() Or... perhaps "has_hit"? Or "ateroid_alive", for a better naming convention. ![]() |
Author: | (O_o) [ Tue Jan 17, 2006 5:29 pm ] | ||
Post subject: | |||
phew.. i got that working, thank you bored. but once again...there is a problem when ever the bullet hits the asteroid it doesn't disappear right away, and some times it does the opposite; it goes away before it touches it... here's the code
|
Author: | (O_o) [ Tue Jan 17, 2006 5:30 pm ] | ||
Post subject: | |||
phew.. i got that working, thank you bored. but once again...there is a problem when ever the bullet hits the asteroid it doesn't disappear right away, and some times it does the opposite; it goes away before it touches it... here's the code
|
Author: | (O_o) [ Tue Jan 17, 2006 5:31 pm ] | ||
Post subject: | |||
phew.. i got that working, thank you bored. but once again...there is a problem when ever the bullet hits the asteroid it doesn't disappear right away, and some times it does the opposite; it goes away before it touches it... here's the code
|
Author: | (O_o) [ Tue Jan 17, 2006 5:32 pm ] | ||
Post subject: | |||
phew.. i got that working, thank you bored. but once again...there is a problem when ever the bullet hits the asteroid it doesn't disappear right away, and some times it does the opposite; it goes away before it touches it... here's the code
|
Author: | (O_o) [ Tue Jan 17, 2006 5:35 pm ] |
Post subject: | |
OPPS how did that happen i'm really sorry about that you can delete the extras if you want |
Author: | Clayton [ Tue Jan 17, 2006 11:33 pm ] |
Post subject: | |
when i tried this program i had a few problems, 1) your collision detection for bullet to asteroid didnt seem to be working at all 2) your collision detection for ship to asteroid didnt seem to be working 3) your Instructions button didnt work, i couldnt figure out how to work it for a while looks good though a little bit more work and im sure itll look good um to tidy up the code a bit, put your asteroid variables(the random ones) into an array, just makes it look better(the code) good job so far |
Author: | (O_o) [ Wed Jan 18, 2006 4:22 pm ] |
Post subject: | |
1) the detection worked for me but as i said before when ever the bullet hits the asteroid it doesn't disappear right away, and some times it does the opposite; it goes away before it touches it... 2)i haven't made one yet 3)i plan to tidy when i finish it. and i tried to make it in an array but then they would all be the same random digit. thanks for the comments |