
-----------------------------------
stickdude32
Tue Jan 05, 2010 9:04 am

trying to track my ship
-----------------------------------
What is it you are trying to achieve?
collision on the ship and shooting lasers from the front


What is the problem you are having?
cant 'locate' the ships position


Describe what you have tried to solve this problem
drwing a circle at the ships variable

Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)








Please specify what version of Turing you are using
4.1

-----------------------------------
stickdude32
Tue Jan 05, 2010 9:15 am

RE:trying to track my ship
-----------------------------------
or do u guys need the pics as well?

-----------------------------------
DemonWasp
Tue Jan 05, 2010 10:29 pm

RE:trying to track my ship
-----------------------------------
To actually run your program, yes, we would need the pictures as well.

That said, I think the reason that using "ship" to draw the oval isn't working is because "ship" refers to the picture ID of a rotated ship image.

-----------------------------------
mirhagk
Wed Jan 06, 2010 8:10 am

RE:trying to track my ship
-----------------------------------
I'd suggest using a type to store all the ship variables for instance

var ship :
    record
        x, y : int
        pic : int
    end record

that would record the position and the pic id of the ship. Of course you would wanna add more to it so that it stores ALL the ships data but that should get you started.

-----------------------------------
stickdude32
Wed Jan 06, 2010 8:43 am

Re: RE:trying to track my ship
-----------------------------------
To actually run your program, yes, we would need the pictures as well.

That said, I think the reason that using "ship" to draw the oval isn't working is because "ship" refers to the picture ID of a rotated ship image.

there u go. u can delete those startup stuff.

-----------------------------------
stickdude32
Wed Jan 06, 2010 8:49 am

Re: RE:trying to track my ship
-----------------------------------
I'd suggest using a type to store all the ship variables for instance

var ship :
    record
        x, y : int
        pic : int
    end record

that would record the position and the pic id of the ship. Of course you would wanna add more to it so that it stores ALL the ships data but that should get you started.

thing is... i didn't learn about record. all i was taught was normal movement, puting things at certain places and making a high low game. i learned about the music and other small stuff. so i tried to figure the things of an asteroid game.

-----------------------------------
stickdude32
Wed Jan 06, 2010 8:54 am

Re: trying to track my ship
-----------------------------------
heres the complete folder.

-----------------------------------
stickdude32
Mon Jan 11, 2010 8:38 am

Re: trying to track my ship
-----------------------------------
im running out of time to finish this. :(

-----------------------------------
stickdude32
Mon Jan 11, 2010 8:46 am

Re: RE:trying to track my ship
-----------------------------------
I'd suggest using a type to store all the ship variables for instance

var ship :
    record
        x, y : int
        pic : int
    end record

that would record the position and the pic id of the ship. Of course you would wanna add more to it so that it stores ALL the ships data but that should get you started.

thing is... i didn't learn about record. all i was taught was normal movement, puting things at certain places and making a high low game. i learned about the music and other small stuff. so i tried to figure the things of an asteroid game.

nvm, i figured it out...slightly

-----------------------------------
Ktomislav
Mon Jan 11, 2010 8:59 am

Re: trying to track my ship
-----------------------------------
X coordinate of the lower left corner of the ship is variable x, y coordinate of the lower left corner of the ship is variable y.
X coordinate of the upper right corner of the ship is variable x+Pic.Width(ship), y coordinate of the upper right corner of the ship is variable y+Pic.Height(ship).

Is that what you wanted?

-----------------------------------
stickdude32
Tue Jan 12, 2010 8:48 am

Re: trying to track my ship
-----------------------------------
X coordinate of the lower left corner of the ship is variable x, y coordinate of the lower left corner of the ship is variable y.
X coordinate of the upper right corner of the ship is variable x+Pic.Width(ship), y coordinate of the upper right corner of the ship is variable y+Pic.Height(ship).

Is that what you wanted?

i dunno i fiddled around with that but it didnt quite work i way i thought it would. could you put into a code that goes with the file.

-----------------------------------
Euphoracle
Tue Jan 12, 2010 9:42 am

RE:trying to track my ship
-----------------------------------
Why can't you put it into code? :S

Save the position of your ship from moveShip to a variable you define at the top of your program and then you can 'locate' it anywhere.

Ktomislav's post refers to 'collision detection'.  Basically, if you know where the ship is located on the screen (your original question) in terms of x position and y position, and you know the height and width of the image (Turing has functions for this), then you can check if two squares are within the bounds of each other using math (as described in the Turing Tutorial forum).

http://i272.photobucket.com/albums/jj190/euphoracle/Computer/collision.png

-----------------------------------
Ktomislav
Tue Jan 12, 2010 9:51 am

Re: trying to track my ship
-----------------------------------
Also you don't use sprites correctly because you define variable ship as
a picture, but use it as a sprite.

-----------------------------------
stickdude32
Wed Jan 13, 2010 8:48 am

Re: RE:trying to track my ship
-----------------------------------
Why can't you put it into code? :S

Save the position of your ship from moveShip to a variable you define at the top of your program and then you can 'locate' it anywhere.

Ktomislav's post refers to 'collision detection'.  Basically, if you know where the ship is located on the screen (your original question) in terms of x position and y position, and you know the height and width of the image (Turing has functions for this), then you can check if two squares are within the bounds of each other using math (as described in the Turing Tutorial forum).

thats the thing. im trying to find the ships position, but i cant. the variables for the ship are not at the ship actual position. there way up and over the outer edge.

-----------------------------------
stickdude32
Wed Jan 13, 2010 8:52 am

Re: trying to track my ship
-----------------------------------
this is the code of it now.

-----------------------------------
Ktomislav
Wed Jan 13, 2010 9:04 am

Re: trying to track my ship
-----------------------------------
You are doing it wrong. Ship isn't the position of the ship, it is a picure.
Try this:
Draw.Oval (x + Pic.Width (shipmove) div 2,y  + Pic.Height (shipmove) div 2,1,1,brightblue)

And you should resize your picture to be the same size as your ship is s that there is ono white left/right/up/down of your ship.

-----------------------------------
TheGuardian001
Wed Jan 13, 2010 9:06 am

Re: trying to track my ship
-----------------------------------

thats the thing. im trying to find the ships position, but i cant. the variables for the ship are not at the ship actual position. there way up and over the outer edge.


You aren't telling it to draw where the ship is, you're telling it to draw at the coordinates reffered to by the variable "ship".

When you use Pic.FileNew, it returns an integer value (normally 1 for the first image), so you're telling it to draw at (1,1). What coordinates did you use to tell it where to draw the ship?

-----------------------------------
stickdude32
Wed Jan 13, 2010 9:13 am

Re: trying to track my ship
-----------------------------------
You aren't telling it to draw where the ship is, you're telling it to draw at the coordinates reffered to by the variable "ship".

When you use Pic.FileNew, it returns an integer value (normally 1 for the first image), so you're telling it to draw at (1,1). What coordinates did you use to tell it where to draw the ship?[/quote]

its using a div 2 and being placed near the center of the window.

-----------------------------------
Ktomislav
Wed Jan 13, 2010 9:27 am

Re: trying to track my ship
-----------------------------------
It is not pic div 2, it is the hight of the picure div 2.
y+Pic.Height(pic) div 2 is Y coordinate the center of a picture.

Please ask your teacher to explain it to you because it seems that you don't understand the way this is working. By doing so you will save a lot of time to you and us and you will understand it better.

-----------------------------------
TheGuardian001
Wed Jan 13, 2010 9:35 am

Re: trying to track my ship
-----------------------------------
I think you're confused about exactly what "ship" is.

"ship" is a variable turing uses to refer to a picture. This picture can be drawn any number of times in any number of locations. when you say:

do refer to the location of the ship. Those are the coordinates of the ship in your window. If you want to know where your ship is, you should be checking those variables.

-----------------------------------
stickdude32
Fri Jan 15, 2010 8:37 am

Re: trying to track my ship
-----------------------------------
well i looked at all the spot where x and y are. thing is, there real statements so i cant use them...yet

-----------------------------------
TheGuardian001
Fri Jan 15, 2010 8:44 am

Re: trying to track my ship
-----------------------------------
well i looked at all the spot where x and y are. thing is, there real statements so i cant use them...yet

Does that matter? They were real values when you used them to draw the ship. Use the same method you used there (It's literally exactly the same line. You can copy past that line and swap out the image name, and it would work).

-----------------------------------
stickdude32
Fri Jan 15, 2010 8:49 am

Re: trying to track my ship
-----------------------------------

Does that matter? They were real values when you used them to draw the ship. Use the same method you used there (It's literally exactly the same line. You can copy past that line and swap out the image name, and it would work).

nvm i found out that i used round to find the ship.

-----------------------------------
stickdude32
Fri Jan 15, 2010 9:10 am

Re: trying to track my ship
-----------------------------------
hooray it has tracked the ships position. thanks
