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

Username:   Password: 
 RegisterRegister   
 whatdotcolour collision
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
shoobyman




PostPosted: Sat Nov 25, 2006 3:07 pm   Post subject: whatdotcolour collision

code:
                if bdgotox (i) > builderx (i) and whatdotcolour (builderx (i) + 10, buildery (i)) = 27 then
                    builderx (i) += 1
                elsif bdgotox (i) < builderx (i) and whatdotcolour (builderx (i) - 10, buildery (i)) = 27 then
                    builderx (i) -= 1
                end if
                if bdgotoy (i) > buildery (i) and whatdotcolour (builderx (i), buildery (i) + 10) = 27 then
                    buildery (i) += 1
                elsif bdgotoy (i) < buildery (i) and whatdotcolour (builderx (i), buildery (i) - 10) = 27 then
                    buildery (i) -= 1
                end if


I am making an RTS and i am trying to make collision for the builder unit. If he moves into an area that is not colour 27 (grey), he should not be able to move. but the problem is that when he moves diagonally he can move into non grey parts a little. This really messes things up because he can move ontop of other builders and then you lose control of him Sad. Anyone know how to fix this?
Sponsor
Sponsor
Sponsor
sponsor
Windsurfer




PostPosted: Sat Nov 25, 2006 6:42 pm   Post subject: (No subject)

I find that the easiest thing to do for full-stop collision is to make a "following" variable that you use for when it collides. Basically, you set the variable to the location of the object (or builder) then get the builder (or object) to move as it would normally. If it is overlapping grey, simply reposition the object to the "following" variable, as it will be at it's last position. Simple!
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  [ 2 Posts ]
Jump to:   


Style:  
Search: