Computer Science Canada

problem with firing with pictures

Author:  winnie:) [ Sat Jan 19, 2008 9:58 pm ]
Post subject:  problem with firing with pictures

basically what I have is an image to use so that when you fire with the space bar it will shoot out. I got it to exit when the bullet reaches a certain place but then when it exits the picture arrives there as well. I know it has something to do with the variables because I used x and y for pictures and the bullets but I have no clue on how to get around it Confused . Any ideas or is this even possible? Here is a quick snippet of the code:
code:

if move = chr (32) then
        loop
       
            drawfilloval (x+25, y+75, 3, 3, blue)
            drawfilloval (x+25, y+75, 2, 2, yellow)
           
            delay (10)
           
            x:= x+5
            if  x> 600 then exit
           
           
            end if
        end loop

Author:  TokenHerbz [ Sat Jan 19, 2008 10:13 pm ]
Post subject:  RE:problem with firing with pictures

Use different variables, Why would you share the x,y location with a gun and the bullet which moves away.

What you should do is create the bullets variables to use instead, thus leaving your picture where it should be, and moving the bullet to where it should be.

Edit: typing errors.

Author:  winnie:) [ Sat Jan 19, 2008 10:53 pm ]
Post subject:  Re: problem with firing with pictures

I get what your saying but then if I declare the bullets as different variables how can I get them to come out of the picture? I checked the tutorials but i didn't see anything. Maybe because it so simple Neutral

Edit: I changed the variables but then a number of other problems occurred such as it only fired once and the place where the bullet comes out of stays stationary so if the picture moves, the bullet doesn't. Any help would be greatly appreciated

Author:  TokenHerbz [ Sun Jan 20, 2008 10:37 am ]
Post subject:  RE:problem with firing with pictures

Alright, So if you have knowledge of flexible arrays, i recommend you use those for spawning and deleting your bullets. If not, your next best option is the following.

basically what you need to do is when you shoot your bullet, you have to declare and set your bullets spawn vars to where the the gun tip is. From there you use your procedure or function to move the bullet, where you get out of the loop when the bullets done moving. The latter is problematic and restricts your game.

Look up flexible arrays, If you have a good understanding of normal arrays, and 2D arrays, this shouldn't be a difficult learning curve.

Heres the link for a great tut on arrays:
http://compsci.ca/v3/viewtopic.php?t=14333

Author:  winnie:) [ Sun Jan 20, 2008 1:18 pm ]
Post subject:  RE:problem with firing with pictures

thank you for the help.


: