Computer Science Canada Can't Create Multiple Bullets |
Author: | hamid14 [ Sun Nov 29, 2009 8:44 pm ] | ||
Post subject: | Can't Create Multiple Bullets | ||
What is it you are trying to achieve? I want to be able to make multiple bullets when pressing the spacebar What is the problem you are having? It deletes the already existing bullet, and creates another one. Describe what you have tried to solve this problem I've thought about it and tried using counters, but doesnt work. Post any relevant code (You may choose to attach the file instead of posting the code if it is too long) Here's the code.
Please specify what version of Turing you are using 4.1 |
Author: | Tony [ Sun Nov 29, 2009 8:52 pm ] | ||
Post subject: | RE:Can\'t Create Multiple Bullets | ||
could you explain this part of your code?
How many times are bullets (drawfilloval) drawn, and at what location(s)? |
Author: | hamid14 [ Sun Nov 29, 2009 8:57 pm ] |
Post subject: | Re: Can't Create Multiple Bullets |
For the bullet to appear, bulletstart has to be true and bulletcounter has to be greater than 1. The count goes up by 10, and when it is 400 the bulletstart is set to false and bulletcounter is set to zero. The bullet_x and bullet_y are equal to posx and posy of the main player. It's in a procedure which I forgot to include, sorry. It looks like this; var chars : array char of boolean var bulletstart : boolean var bulletcounter := 0 var count : int := 0 var bullet_x, bullet_y : int var posx, posy : int := 100 proc bullets bullet_x := posx bullet_y := posy end bullets loop Input.KeyDown (chars) if chars (' ') then bulletstart = true bullets end if if bulletstart = true and bulletcounter > 0 then count += 10 drawfilloval (bullet_x + count, bullet_y, 5, 5, 9) end if drawfilloval (posx,posy,10,10,red) end loop |
Author: | Tony [ Sun Nov 29, 2009 9:25 pm ] |
Post subject: | RE:Can\'t Create Multiple Bullets |
You might notice that the description has no mention of having multiple bullets. You might need to change something about the design. |
Author: | B-Man 31 [ Sun Nov 29, 2009 11:51 pm ] |
Post subject: | RE:Can\'t Create Multiple Bullets |
also, your gonna need to learn about arrays, preferably flexible ones, they will help you out a lot. |
Author: | Kharybdis [ Mon Nov 30, 2009 11:04 am ] |
Post subject: | RE:Can\'t Create Multiple Bullets |
For what b-man 31 said, to create multiple bullets, you're going to need a flexible array where it's going to keep creating bullets when you press the space bar and after a certain bullet_time_length, take away the parts of the flexible array so you have it starting at 0 again. This is an easy method, but note that the more bullets you have, the laggier it's going to get. |