Computer Science Canada Check my code -- I cant get it to run smoothly |
Author: | Khrist [ Fri Apr 15, 2005 8:10 am ] | ||
Post subject: | Check my code -- I cant get it to run smoothly | ||
ok, ive been playing around with some things and im just learning how to use procedures and processes. I am just making this fun little game where you have 2 players on a team and they will shoot down enemies. I am only in the very primal states of the game but im having problems with the shooting. If i try and shoot, it either erases my guy, shoots off 10 bullets and once, or my guy cannot move until the bullet is gone. If anyone can help me here, im sure its probably something like an organization problem. Anyways heres the code:
|
Author: | Delos [ Fri Apr 15, 2005 8:17 am ] |
Post subject: | |
You do realise that if we're to 'check your code', we would actually have to be able to run it to debug it. No, we're not going to sift through it and try read it off... In other words, this is not going any where w/out those pics you've got as part of it. But wait! There's more. How about instead of posting all the code, you post the parts you think are screwing things up. Again, ensure that this code will run w/ the press of F1. Though just from glancing over it, you might be in need of some cls' here and there...again, I can't tell unless I can run it. |
Author: | jamonathin [ Fri Apr 15, 2005 8:24 am ] | ||
Post subject: | |||
Yes, and please dont post the pictures individually. Put the program and the pictures into a zip/rar file. But by looking at your program, I suggest your main loop look like this:
|
Author: | c0bra54 [ Wed Apr 20, 2005 12:39 am ] | ||
Post subject: | |||
also, if u are doing a shooter, you will be tempted (sice it is soooo easy) to do a simple delay (x) for your time delay.. but don't!!! that is the worst, because if your main loop takes longer the execute, it'll still wait the same length.. what you need is (i call it this) FPS limiting code.. or code that sets a max for the FPS of your game, and it will always be that.. the code looks something like this.. put it at the VERY end of your main loop righ before the View.Update, or it won't work right..
|
Author: | Bacchus [ Wed Apr 20, 2005 3:27 pm ] |
Post subject: | |
or just use Time.DeaySiceLast() |
Author: | Martin [ Wed Apr 20, 2005 4:31 pm ] |
Post subject: | |
Please make a more descriptive title for your topic, Khrist. |
Author: | Cervantes [ Wed Apr 20, 2005 4:32 pm ] | ||||
Post subject: | |||||
jamonathin wrote: Yes, and please dont post the pictures individually. Put the program and the pictures into a zip/rar file.
But by looking at your program, I suggest your main loop look like this:
That's an akward loop structure. First off, you should not have any variable declaration within your loop. Move all that before the loop. Secondly, the cls should go with the drawing, just to keep things organized. the draw procedure should then also go with the drawing (at the end) to keep things organized. Lastly, I like to go with the whole input -> processing -> output approach, so I'd go like this:
I'm not sure what ai and fight do though, so perhaps they should go elsewhere. Hopefully you get my idea, though. |
Author: | c0bra54 [ Wed Apr 20, 2005 8:01 pm ] |
Post subject: | |
and about Time.DelaySinceLast... well some ppl still have 4.0.4 since they can't get there hands on 4.0.5, plus my Teacher has the old one so ![]() |