Computer Science Canada shooting problems |
Author: | upthescale [ Sat Apr 01, 2006 12:42 pm ] | ||
Post subject: | shooting problems | ||
Ok, down below is some code. I want it to, when I hit enter, shoot the square from the first square on the left.
If you can fix it up it would be great! Mod Edit: Sure thing. Spelling and grammar has been fixed up and code tags added. |
Author: | Cervantes [ Sat Apr 01, 2006 1:00 pm ] | ||
Post subject: | |||
Avoid processes! You don't need them for this sort of thing (if I understand what you're trying to do -- haven't run the code). upthescale wrote:
This is a problem. This means that whenever you press enter, a box will move, but the rest of your program will halt completely. No, the solution to this does not involve a process. Rather, you need to make a new pseudo-object (easily done with records and flexible arrays [see below]) that has certain properties such as position and velocity. Apply these properties (position += velocity) in the main loop. Check out the Flexible Arrays Tutorial (link in Turing Walkthrough). It's got an example of shooting. |
Author: | pavol [ Sat Apr 01, 2006 1:04 pm ] |
Post subject: | |
all you have to do is make bulletx and bullety equal x and y that way the bullet will come out of the box on the bottom left. and i am curious as to why you are using mousewhere otherwise i hope it helps |