Computer Science Canada

trying to track my ship

Author:  stickdude32 [ Tue Jan 05, 2010 9:04 am ]
Post subject:  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)
<Answer Here>

Turing:


<Add your code here>



Please specify what version of Turing you are using
4.1

Author:  stickdude32 [ Tue Jan 05, 2010 9:15 am ]
Post subject:  RE:trying to track my ship

or do u guys need the pics as well?

Author:  DemonWasp [ Tue Jan 05, 2010 10:29 pm ]
Post subject:  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.

Author:  mirhagk [ Wed Jan 06, 2010 8:10 am ]
Post subject:  RE:trying to track my ship

I'd suggest using a type to store all the ship variables for instance
Turing:

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.

Author:  stickdude32 [ Wed Jan 06, 2010 8:43 am ]
Post subject:  Re: RE:trying to track my ship

DemonWasp @ Tue Jan 05, 2010 10:29 pm wrote:
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.

Author:  stickdude32 [ Wed Jan 06, 2010 8:49 am ]
Post subject:  Re: RE:trying to track my ship

mirhagk @ Wed Jan 06, 2010 8:10 am wrote:
I'd suggest using a type to store all the ship variables for instance
Turing:

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.

Author:  stickdude32 [ Wed Jan 06, 2010 8:54 am ]
Post subject:  Re: trying to track my ship

heres the complete folder.

Author:  stickdude32 [ Mon Jan 11, 2010 8:38 am ]
Post subject:  Re: trying to track my ship

im running out of time to finish this. Sad

Author:  stickdude32 [ Mon Jan 11, 2010 8:46 am ]
Post subject:  Re: RE:trying to track my ship

stickdude32 @ Wed Jan 06, 2010 8:49 am wrote:
mirhagk @ Wed Jan 06, 2010 8:10 am wrote:
I'd suggest using a type to store all the ship variables for instance
Turing:

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

Author:  Ktomislav [ Mon Jan 11, 2010 8:59 am ]
Post subject:  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?

Author:  stickdude32 [ Tue Jan 12, 2010 8:48 am ]
Post subject:  Re: trying to track my ship

Ktomislav @ Mon Jan 11, 2010 8:59 am wrote:
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.

Author:  Euphoracle [ Tue Jan 12, 2010 9:42 am ]
Post subject:  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).

Posted Image, might have been reduced in size. Click Image to view fullscreen.

Author:  Ktomislav [ Tue Jan 12, 2010 9:51 am ]
Post subject:  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.

Author:  stickdude32 [ Wed Jan 13, 2010 8:48 am ]
Post subject:  Re: RE:trying to track my ship

Euphoracle @ Tue Jan 12, 2010 9:42 am wrote:
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.

Author:  stickdude32 [ Wed Jan 13, 2010 8:52 am ]
Post subject:  Re: trying to track my ship

this is the code of it now.

Author:  Ktomislav [ Wed Jan 13, 2010 9:04 am ]
Post subject:  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:
Turing:
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.

Author:  TheGuardian001 [ Wed Jan 13, 2010 9:06 am ]
Post subject:  Re: trying to track my ship

stickdude32 wrote:

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?

Author:  stickdude32 [ Wed Jan 13, 2010 9:13 am ]
Post subject:  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.

Author:  Ktomislav [ Wed Jan 13, 2010 9:27 am ]
Post subject:  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.

Author:  TheGuardian001 [ Wed Jan 13, 2010 9:35 am ]
Post subject:  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:

code:

Draw.Oval (ship,ship,50,50,brightblue)


You are attempting to use a picture id (probably 1) as a coordinate. So you're saying to draw an oval at (1,1). "ship" does not now, nor will it ever, refer to the location of the ship. It is used only by Turing to refer to the image file you loaded.

Now, when you draw the ship itself, you use this:
code:

Pic.Draw (ship, round (x), round (y), picMerge)


The variables "x" and "y", unlike "ship" 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.

Author:  stickdude32 [ Fri Jan 15, 2010 8:37 am ]
Post subject:  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

Author:  TheGuardian001 [ Fri Jan 15, 2010 8:44 am ]
Post subject:  Re: trying to track my ship

stickdude32 @ Fri Jan 15, 2010 8:37 am wrote:
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).

Author:  stickdude32 [ Fri Jan 15, 2010 8:49 am ]
Post subject:  Re: trying to track my ship

TheGuardian001 @ Fri Jan 15, 2010 8:44 am wrote:

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.

Author:  stickdude32 [ Fri Jan 15, 2010 9:10 am ]
Post subject:  Re: trying to track my ship

hooray it has tracked the ships position. thanks


: