shooting from a picture
Author |
Message |
w00t
![](http://www.thefurrymonkey.co.uk/picmuppet.gif)
|
Posted: Thu Dec 16, 2004 5:17 pm Post subject: shooting from a picture |
|
|
Okay, I think i've officially hit the wall of STUPIDITY and it hurts!
I'm making a space invaders game for my ISU and now i have the ship movement the alien movement and i even have the extremly chessy music.. but how can i get the space ship to shoot, i can draw a line but how do you draw a line from the "spaceship" when its always moving?
I dont know if thats very clear, if it isn't ill give it another go at it..
thnx alot
w00t |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Thu Dec 16, 2004 5:25 pm Post subject: (No subject) |
|
|
your question is vague, but my guess would be that you should draw your line independant of the ship. Such the line has a set of its own variables that are synced to the ship when the line is created, but are independant afterwards |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
Delos
![](http://www.members.shaw.ca/rfolz/delos_avatar.gif)
|
Posted: Thu Dec 16, 2004 5:25 pm Post subject: (No subject) |
|
|
You're 'line' can be considered an object with behaviours and characteristics.
For example, it has an x- and y- value, a life-span, a length, a power setting, etc etc.
It terms of keeping the line in the same place as the ship...simply ensure that the x-values always match up (assuming your ship can only move left-right). If you have more complex movement, then keep the x- and y- values the same. Of course by 'the same' I mean 'in the same place that they should be, be it at SpaceShipPic.x and SpaceShipPic.y or (SpaceShipPic.x + 4) and (SpaceShipPic.y + 7)...assuming that (4,7) pixels away from the bottom left hand corner of your pic is the part that looks like the gun...'
Make sense? No? Ah well.
Make required x- and y- values match up. |
|
|
|
|
![](images/spacer.gif) |
w00t
![](http://www.thefurrymonkey.co.uk/picmuppet.gif)
|
Posted: Thu Dec 16, 2004 5:46 pm Post subject: (No subject) |
|
|
okay
i have my space ship move on the X axis left and right, when i press down its suppose to shoot a "laser / projectile " at the evil furby. i can get the collison but how do i get the "porjecitle" to shoot from my ship.. i didn't understand the previous post completly..
if you want code it post it for you. |
|
|
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
Posted: Sat Dec 18, 2004 12:14 pm Post subject: (No subject) |
|
|
If I understand correctly, you are now looking more towards shooting bursts of lasers as opposed to a constant stream. If that's the case, Flexible Arrays are going to be your best friend. ![Smile Smile](http://compsci.ca/v3/images/smiles/icon_smile.gif) |
|
|
|
|
![](images/spacer.gif) |
MihaiG
![](http://compsci.ca/v3/uploads/user_avatars/2070081168483773c3dead4.png)
|
|
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
Posted: Mon Dec 20, 2004 8:11 pm Post subject: (No subject) |
|
|
I fail to see how that relates to the question asked.
(Note that the above statement is not a question. If you see it as one, please, see it as a rhetorical question.) |
|
|
|
|
![](images/spacer.gif) |
MihaiG
![](http://compsci.ca/v3/uploads/user_avatars/2070081168483773c3dead4.png)
|
Posted: Mon Dec 20, 2004 8:34 pm Post subject: (No subject) |
|
|
the rain is essentialy like the laser.... it draws its self thne again 1 pixel down..... using an array... but you can make it for just one buller/ beam every 100ms so you don't get like .... or the moving speed so it does go off the screen in 1 / 2 *s |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
Posted: Tue Dec 21, 2004 7:49 am Post subject: (No subject) |
|
|
The difference is, you will always have a specific number of "lasers" (or raindrops) if you use an array. However, when you use a flexible array, you've got just the right number of elements to store the bullets (or lasers) that are onscreen. |
|
|
|
|
![](images/spacer.gif) |
w00t
![](http://www.thefurrymonkey.co.uk/picmuppet.gif)
|
Posted: Tue Dec 21, 2004 8:28 am Post subject: (No subject) |
|
|
okay, thnx for showing me how to shoot, but im still a little foggy on this question..
How do i shoot from a picture if its constantly moving along the X-axis ... because if i wantto draw a line that was green it would be
drawline (10,10,10,50,green)
but now I"ve hardcoded the line and can't make the x and y coordinates a varible unless you can. then please inform me on how to do so...
tnx in advance
w00t |
|
|
|
|
![](images/spacer.gif) |
Delos
![](http://www.members.shaw.ca/rfolz/delos_avatar.gif)
|
Posted: Tue Dec 21, 2004 9:52 am Post subject: (No subject) |
|
|
code: |
var x, y1, y2 : int := 0
y1 := 20
y2 := 100
for i : 1..20
drawline (x, y1, x, y2, green)
delay (20)
x += 3
cls
end for
|
|
|
|
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
Posted: Tue Dec 21, 2004 9:56 am Post subject: (No subject) |
|
|
Create a variable to store the position of your picture (I'll call it shipX). Since Pic.Draw draws from the bottom left, shipX will not be the middle of your ship, but the left of your ship. So, in your if statements, you'd have to take into account that fact. Personally, I prefer to have my variables store the middle value of the picture. To achieve this, try doing this:
code: |
Pic.Draw (ship, round (shipX - (Pic.Width (ship) / 2)), 10, picCopy)
|
Now, say your gun is in the middle of the ship. Just create a new element of your flexible array and shoot a bullet out, using shipX for that bullet's x value (note that you set the x value when you fire the bullet. You don't change it after it has been fired). |
|
|
|
|
![](images/spacer.gif) |
w00t
![](http://www.thefurrymonkey.co.uk/picmuppet.gif)
|
Posted: Tue Dec 21, 2004 6:57 pm Post subject: (No subject) |
|
|
Thanks Alot!
It works, as soon as i have the game complete ill post it, it even comes with amusing animations! it shall be a success
tnx w00t ![Wink Wink](http://compsci.ca/v3/images/smiles/icon_wink.gif) |
|
|
|
|
![](images/spacer.gif) |
|
|