Computer Science Canada Shooting bullets |
Author: | platky [ Wed Feb 25, 2009 9:03 pm ] |
Post subject: | Shooting bullets |
Im having a terrible problem with getting my shooting to work. So far there is a little box that shoots at me using a rand.int. When the attack procedure is activatated the bullet is supposed to come out. The bullet moves with coding bullet_x-=25 which does move the bullet but not at a continuos speed. It moves but only in increments when the rand.int statement is true. Anybody have any ideas on this. i will post code if anyone wants to see it... |
Author: | saltpro15 [ Wed Feb 25, 2009 9:06 pm ] |
Post subject: | RE:Shooting bullets |
why use rand.int anyway? and posting the code would be helpful |
Author: | platky [ Thu Feb 26, 2009 8:30 am ] | ||
Post subject: | Re: Shooting bullets | ||
Heres the code
|
Author: | S_Grimm [ Thu Feb 26, 2009 12:12 pm ] | ||||||
Post subject: | RE:Shooting bullets | ||||||
1) Post the source code and the [colour="red"]PICTURES[/colour] in a .zip file and post them as an attachment. I can't compile without them. 2)
Should be in it's own procedure. call it something like IsAttacking. 3)
The cls Deletes the Bullet from the screen. Use an array to track if bullets are on the screen and a procedure to move them ie
|
Author: | platky [ Thu Feb 26, 2009 2:19 pm ] | ||||
Post subject: | RE:Shooting bullets | ||||
im getting a few errors:
says there is an expected ":" on int this happens in both cases where it is written another error is
it says it is the wrong type... |
Author: | DemonWasp [ Thu Feb 26, 2009 7:04 pm ] | ||||
Post subject: | RE:Shooting bullets | ||||
That's because
is C, C++, Java or one of a bunch of related languages. The turing equivalent is:
The other one is probably a type mismatch between integer (int) and floating-point (real). You can use the methods round, floor or ceil to convert from a real number to an integer, depending on what you want. @AJ: Apparently the board only likes the US spelling - "color". Kinda stupid, but then it's probably more effort to change than its worth. |
Author: | S_Grimm [ Fri Feb 27, 2009 6:48 am ] |
Post subject: | RE:Shooting bullets |
oops my bad. I've been programming in Java for a long time now. Regardless, DemonWasp summed up to solution properly. @DemonWasp: Its AV not AJ. Thanks tho. I wrote the code in the quick reply box, so i dind bother trying to fix it. my bad. |
Author: | platky [ Fri Feb 27, 2009 10:03 am ] | ||
Post subject: | Re: Shooting bullets | ||
Thanks for the help the previous stuff is fixed but i now get a new error...
The error is with the Draw.FIllOval for the bullet. IT says the variable has no value. I have no idea what variable? |
Author: | S_Grimm [ Fri Feb 27, 2009 11:53 am ] |
Post subject: | RE:Shooting bullets |
Ok, i tried to write code myself, based on how i would write it in Java. So, what you have to do is modify it to Turing. The error is either the bulletX(i) or bulletY (i) Edit: Use flexible arrays to keep track of the bullets. then you can use "upper" for the bullets. Once i can use my personal computer, ill post a modified copy of your code using flexible arrays to initalize the bulletList. |
Author: | platky [ Sat Feb 28, 2009 1:54 pm ] |
Post subject: | RE:Shooting bullets |
i still cant seem to fix this problem. Every time i change sumthing a new problem arises... I also cant figure out how to get my guy to change the direction he is facing according to what button is pressed |
Author: | S_Grimm [ Sun Mar 01, 2009 9:02 pm ] |
Post subject: | RE:Shooting bullets |
To change his direction, just flip the image in paint or photoshop and then import it as a second sprite. Then, have a boolean state so when left arrow is pressed it draws left (ie facingLeft = true) or vise versa |
Author: | platky [ Tue Mar 03, 2009 10:44 am ] | ||
Post subject: | Re: Shooting bullets | ||
Instead of making my enemy shoot i decided to work on making my character shoot. The problem is that when i use cls and view.update the screen gets messed up. When i dont the bullet is a continuos beam... any ideas?
|
Author: | S_Grimm [ Wed Mar 04, 2009 12:42 pm ] | ||||||
Post subject: | Re: Shooting bullets | ||||||
Error #1
Error #2 Your if statements inside the loop Use procedures. Also Take the View.Update and cls out of the for loop
|
Author: | platky [ Wed Mar 04, 2009 1:37 pm ] | ||
Post subject: | Re: Shooting bullets | ||
I just noticed i made a huge mistake and copied someone elses code into it that i was looking at. Here is my actually code:
sorry about that |
Author: | S_Grimm [ Thu Mar 05, 2009 12:50 am ] | ||||
Post subject: | RE:Shooting bullets | ||||
try
to
|
Author: | platky [ Thu Mar 05, 2009 9:47 am ] | ||
Post subject: | RE:Shooting bullets | ||
this is actually the portion that im having problems with. The sprite stuff is just garbage...
|
Author: | S_Grimm [ Thu Mar 05, 2009 11:58 am ] | ||
Post subject: | RE:Shooting bullets | ||
try this
|
Author: | platky [ Thu Mar 05, 2009 12:15 pm ] |
Post subject: | RE:Shooting bullets |
then it is just a continuos beam... |