Computer Science Canada need help with a program |
Author: | Darkmantis [ Sat Apr 22, 2006 1:25 pm ] |
Post subject: | need help with a program |
is there a way to disable a key on the key board while a program is running? |
Author: | Darkmantis [ Sat Apr 22, 2006 1:55 pm ] |
Post subject: | |
the program I need help with is a side scroller im working on here it is it may be crap right now but im just trying to get a jumping system to work but im having a hard time with it. |
Author: | NikG [ Sat Apr 22, 2006 11:31 pm ] |
Post subject: | |
What exactly do you mean? Why do you need to disable a key? |
Author: | Darkmantis [ Sun Apr 23, 2006 1:48 pm ] |
Post subject: | |
well im thinking of disabling the up key so u cant press it while the character is in the air and then enable it again afterward |
Author: | GlobeTrotter [ Sun Apr 23, 2006 2:40 pm ] | ||
Post subject: | |||
Then you don't need to disable the key. You just need to put an if statement where the up key performs an action. Just make sure the person is on the ground before performing the jump action. eg: pseudocode:
|
Author: | Darkmantis [ Sun Apr 23, 2006 6:49 pm ] | ||
Post subject: | |||
So u are saying I should use a code like this to use?
thx this should really help with the development of my program ![]() ![]() ![]() |
Author: | Darkmantis [ Sun Apr 23, 2006 8:17 pm ] |
Post subject: | |
I tryed out the code and my program still glitches up when I click the jump butten while a jump is in progress. |
Author: | cool dude [ Sun Apr 23, 2006 8:38 pm ] | ||
Post subject: | |||
try this pseudo code! similar to GlobeTrotter
|
Author: | Darkmantis [ Mon Apr 24, 2006 6:16 am ] |
Post subject: | |
what the hell is pseudo code??? |
Author: | cool dude [ Mon Apr 24, 2006 10:09 am ] |
Post subject: | |
Darkmantis wrote: what the hell is pseudo code???
u don't know wat pseudo code is? ![]() its like code made in comments. the reason i gave u pseudo code is because thats how u do it, but u can't copy and paste the code because u didn't use the same variable names! basically take my code and stick in the variable names u used and i think it should work! ![]() oh and i forgot to mention after my code when the jump was finished just set the variable jump back to false so u can jump again. |
Author: | Darkmantis [ Mon Apr 24, 2006 10:43 am ] |
Post subject: | |
Lol ok awesome thats wat I did. But now I can jump without it glitching except I can jump in midair over and over for some reason but it shouldn't let me. |
Author: | cool dude [ Mon Apr 24, 2006 4:55 pm ] |
Post subject: | |
if u used my code correctly than that wouldn't happen because it would never call the jump procedure since the boolean is set to true which means your in the air already. post your new code and i'll take a look at it |
Author: | cool dude [ Mon Apr 24, 2006 5:01 pm ] |
Post subject: | |
***Edit*** the code that u already posted is terrible!!! why do u have 4 timers??? and it completely doesn't work! tell me what you are trying to do and post the updated code |
Author: | Darkmantis [ Mon Apr 24, 2006 5:26 pm ] | ||
Post subject: | |||
Here is my updated version with the new code, but as u said the timer thing is kinda hard to get to work if u can help me out with this it would be awesome, and ill post the code to for people who are too lazy to download the program.
|
Author: | Darkmantis [ Mon Apr 24, 2006 5:27 pm ] |
Post subject: | |
LOL FORGOT TO POST THE ZIP FILE |
Author: | cool dude [ Mon Apr 24, 2006 6:24 pm ] |
Post subject: | |
here ![]() |
Author: | Darkmantis [ Tue Apr 25, 2006 5:40 am ] |
Post subject: | |
wow, thats awesome thanks a lot ![]() |
Author: | Darkmantis [ Tue Apr 25, 2006 6:37 am ] |
Post subject: | |
Does anyone have any good code that I can use to get my guy to jump and land on a platform? |
Author: | cool dude [ Tue Apr 25, 2006 1:10 pm ] |
Post subject: | |
Darkmantis wrote: Does anyone have any good code that I can use to get my guy to jump and land on a platform?
u don't ask for code because thats not wat we r here for. we are here to help u and not give u free code which i kinda already did. why don't u rephrase your question and ask how do i do collision detection |
Author: | Darkmantis [ Tue Apr 25, 2006 2:41 pm ] | ||
Post subject: | |||
well I already have code but Im not sure how to use it or reliable it is. This code is from a game I did at school almost like pong but the player paddles were on the top and bottem instead of the left and right. Here it is:
|
Author: | cool dude [ Tue Apr 25, 2006 3:33 pm ] | ||||||
Post subject: | |||||||
k your code is kinda pointless. collision detection is really simple. i'll help u get started by helping u with the left side of the box collision detection and then u could implement that to get right side and top of the box collision detection. Left Side u want your person to stop moving if it hits the left side so first we need to determine that.
this basically states that if the right side of the persion is greater than the left side of the box. now we determined if it collides with the box so what do we want to do? we want to make the person stop so no matter if the user presses "D" to go left it will not move. to do so we need to say
***Important*** this code u want to put in your form_keypress procedure inside the if statement that is going to the left. so that if statement will look like so...
|
Author: | Darkmantis [ Tue Apr 25, 2006 6:22 pm ] |
Post subject: | |
awesome thx I try to build this into my game ![]() ![]() ![]() |
Author: | Darkmantis [ Tue Apr 25, 2006 6:27 pm ] |
Post subject: | |
Oh umm.. first I need to be able to jump onto the platform so how can I make it jump diagonal? I tried but I can't get it to work by pressing left and up key ![]() |
Author: | cool dude [ Tue Apr 25, 2006 7:23 pm ] |
Post subject: | |
my code was just showing u collision detection so if the person touches the box it won't go through the box. that has nothing to do with jumping diagonally. to jump diagonally u might want to look up something with trig. |
Author: | Darkmantis [ Wed Apr 26, 2006 10:49 am ] |
Post subject: | |
fine be that way ![]() |
Author: | cool dude [ Wed Apr 26, 2006 1:12 pm ] |
Post subject: | |
Darkmantis wrote: fine be that way
![]() i helped u more than enough and i'm not giving u more code! u have to try figuring some stuff on your own because that way u will learn something. i even gave u a quick tutorial on collision detection so u should be thankful. when u try doing it yourself and post the code that u did (not random code put together) and ask a specific question!!! than we might help u more. |
Author: | Darkmantis [ Wed Apr 26, 2006 4:53 pm ] |
Post subject: | |
I already knew the crap U showed me first of all I just wanted to know where to apply it. And second I have a really bad memory! |
Author: | cool dude [ Wed Apr 26, 2006 5:22 pm ] |
Post subject: | |
hahaha u knew that crap! it really doesn't look like u knew it because looking at your first code with your 5 timers it seems u have no idea wat a timer is for and u put a bunch of code together to say its code. as well if u knew it u wouldn't ask for help! u really shouldn't try to piss of a person that helps u because who's goin to help u now eh? |
Author: | GlobeTrotter [ Wed Apr 26, 2006 6:25 pm ] |
Post subject: | |
Trig should not be used to jump diagonally. If you've taken physics 12 (maybe 11) you'll know that horizontal motion of a projectile is independant of the vertical. Thus, simulating gravity in the vy whilst simulating constand horizontal motion in the vx direction is sufficient. The problem with moving diagonally is: you have to recognize two keys being pressed at once. Under your current implementation, this is not possible. You're going to have to completely redesign your keyboard input to use an array(255) of boolean if you wish to allow for simultaneious imput. |
Author: | Darkmantis [ Wed Apr 26, 2006 7:27 pm ] |
Post subject: | |
english plz |
Author: | Darkmantis [ Wed Apr 26, 2006 7:30 pm ] |
Post subject: | |
cool dude wrote: hahaha u knew that crap! it really doesn't look like u knew it because looking at your first code with your 5 timers it seems u have no idea wat a timer is for and u put a bunch of code together to say its code. as well if u knew it u wouldn't ask for help! u really shouldn't try to piss of a person that helps u because who's goin to help u now eh?
obviously not u! that timer thing that ur making fun of is wat I was taught in school first off all.And second of all IM NOT TRYING TO PISS ANYONE OFF IM JUST STARTING THE FUCKING OBVIOUS!! |