Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Moving character's unit collision
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Beaver Tails




PostPosted: Sat Mar 29, 2014 6:38 pm   Post subject: Moving character's unit collision

What is it you are trying to achieve?
<Replace all the <> with your answers/code and remove the <>>


What is the problem you are having?
<Answer Here>


Describe what you have tried to solve this problem
<Answer Here>


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
<Answer Here>



op rpg.rar
 Description:

Download
 Filename:  op rpg.rar
 Filesize:  2.56 KB
 Downloaded:  130 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Beaver Tails




PostPosted: Sat Mar 29, 2014 6:40 pm   Post subject: RE:Moving character\'s unit collision

Sorry, i screwed up the post so heres the edit

What is it you are trying to achieve?
The character to not collide with the shop


What is the problem you are having?
cant get the character to get to not collide with the shop. I've looked unit collision up on the fourms but i'm using true (only 1 of each x and y value) but others are using false (2 of each x and y value).
Insectoid




PostPosted: Sat Mar 29, 2014 7:19 pm   Post subject: RE:Moving character\'s unit collision

Assuming your collision detection is between rectangles, you need to have 2 x and y values per unit. If you only have one x and y, then you probably have a width & height, and can use those to create the 2nd x and y pair. From there, you just do what the tutorials tell you.
Beaver Tails




PostPosted: Mon Mar 31, 2014 10:16 pm   Post subject: RE:Moving character\'s unit collision

characterSprite := Sprite.New (Pic.FileNew ("character.bmp"))
Sprite.SetPosition (characterSprite, x, y, true);
Sprite.Show (characterSprite)

loop
Input.KeyDown(chars)
if chars(KEY_UP_ARROW) then
if y < maxy - 16 then
y := y + moveSpeed
end if
end if
if chars(KEY_DOWN_ARROW) then
if y > 16 then
y:= y - moveSpeed
end if
end if

if chars(KEY_LEFT_ARROW) then
if x > 16 then
x:= x - moveSpeed
end if
end if

if chars(KEY_RIGHT_ARROW) then
if x < maxx - 16 then
x:= x + moveSpeed
end if
end if

Sprite.SetPosition (characterSprite, x, y, true);
delay (10)
end loop



For the sprite, it will only have 2 values since it is on true mode and i don't want to make it false
Insectoid




PostPosted: Tue Apr 01, 2014 6:54 am   Post subject: RE:Moving character\'s unit collision

Use a little math to figure out how to transform those 2 values into the 4 that you need.
Beaver Tails




PostPosted: Wed Apr 02, 2014 5:37 pm   Post subject: RE:Moving character\'s unit collision

you mean creating 4 new values?

(x,y)

x1 = x + 50
x2 = x + 100
???
Insectoid




PostPosted: Wed Apr 02, 2014 8:26 pm   Post subject: RE:Moving character\'s unit collision

You're getting there. Let's say your sprite is 50x50 pixels. (x, y) is in the middle of the picture. To get the top-right corner, you add half the width to the X value and half the height to the Y value; (x+25, y+25). Now that you have the top-right, you only need the bottom-left. How do you think you'd do that?
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: