Computer Science Canada Im made a program but some is not right but it should be |
Author: | Darkmantis [ Mon May 15, 2006 2:46 pm ] | ||
Post subject: | Im made a program but some is not right but it should be | ||
I have this game Im working on where u have 2 tanks and you shoot each other ive only got the movement and shooting code made. I have the movement for both tanks made and it should work but the 1st tank only works for some reason and I cant figure it out. ill also attach the file too. ![]() here is my code:
|
Author: | NikG [ Mon May 15, 2006 3:32 pm ] | ||||
Post subject: | |||||
For some reason, Form_KeyPress doesn't seem to recognize input from the arrow keys. Use Form_KeyUp instead. Also, your code is, for lack of a better word, a mess! Here's some suggestions to clean it up: - Try to use the built in constants for the keyboard input, and use a case statement. i.e:
- Keep a separate variable for the direction of the shot. Right now, the shot will change direction if you change the direction of the tank - Create a image control array for each player. Store the 4 different pics in that control array (so that you'll end up with Tank1 (0)/(1)/(2)/(3). Have a variable to keep track (numerically) of what direction the tank is facing (i.e. Tank1Dir). Then you will be able to use simple code like this:
|
Author: | Darkmantis [ Mon May 15, 2006 4:40 pm ] |
Post subject: | |
lol I have an end if in the wrong place so now it works, but your help will still benefit me thx ![]() ![]() and thx for the help ![]() |
Author: | Darkmantis [ Mon May 15, 2006 4:41 pm ] |
Post subject: | |
oh and 2nd I have no clue how to use arrays Ive never learned them in class, maybe I will next year ![]() |
Author: | Darkmantis [ Mon May 15, 2006 4:53 pm ] |
Post subject: | |
dang, I just noticed another thing thats wrong with my program and its that I cant have both tanks moving at the same time how do I fix that? |
Author: | cool dude [ Mon May 15, 2006 10:15 pm ] |
Post subject: | |
Darkmantis wrote: oh and 2nd I have no clue how to use arrays Ive never learned them in class, maybe I will next year
![]() if u want to learn about arrays which i strongly suggest u do!!!(trust me on that) u can check out this tutorial http://www.compsci.ca/v2/viewtopic.php?t=71 as for your problem with accepting 2 keys at once i'm not sure u can. for example can u press and hold 2 keys at the same time in ms word? no. i might be mistaken but i don't think its possible |
Author: | wtd [ Mon May 15, 2006 11:00 pm ] | ||
Post subject: | |||
Holy copy and paste, batman!
|
Author: | Darkmantis [ Tue May 16, 2006 5:37 am ] | ||
Post subject: | |||
wtd wrote: Holy copy and paste, batman!
ya i only get to use the computer for an hour per day so I prefer to take the fastest route possible. To cooldude: when I make my pong I was able to have both paddles move at the same time so it is possable Im just mixed up and confused |
Author: | wtd [ Tue May 16, 2006 10:20 am ] | ||
Post subject: | |||
Darkmantis wrote: wtd wrote: Holy copy and paste, batman!
ya i only get to use the computer for an hour per day so I prefer to take the fastest route possible. Laziness is a virtue for a programmer. However, this is not an example of true, enlightened laziness, since it creates more work later on. Breaking your code down into a set of well-constructed functions would be much lazier. ![]() |
Author: | Darkmantis [ Tue May 16, 2006 10:45 am ] |
Post subject: | |
wow thats very true. ![]() |
Author: | cool dude [ Tue May 16, 2006 7:00 pm ] |
Post subject: | |
Darkmantis wrote: To cooldude: when I make my pong I was able to have both paddles move at the same time so it is possable Im just mixed up and confused so how did u do it? if u could do that then it should be no problem figuring out how to do it now |
Author: | Darkmantis [ Wed May 17, 2006 6:40 am ] |
Post subject: | |
the problem is I have no clue how I got it to work before, it just works. |
Author: | cool dude [ Wed May 17, 2006 4:20 pm ] |
Post subject: | |
Darkmantis wrote: the problem is I have no clue how I got it to work before, it just works.
post the code! |
Author: | Darkmantis [ Thu May 18, 2006 5:32 pm ] |
Post subject: | |
I dont have it anymore, my computer crashed 2 months ago and I have to get it repaired and everything got deleted off ![]() |