Click here to Skip to main content
15,900,906 members
Please Sign up or sign in to vote.
2.40/5 (5 votes)
See more:
This is my code

C#
if (Death.Location == new Point(Death.Location.X <= 30, Death.Location.Y))
           {
               Death.Location = new Point(Death.Location.X - movement, Death.Location.Y);
           }


these are my errors
VB
Error   1   The best overloaded method match for 'System.Drawing.Point.Point(int, int)' has some invalid arguments  C:\Users\Kyle\documents\visual studio 2010\Projects\Game 1\Game 1\Form2.cs  156 39  Game 1


VB
Error   2   Argument 1: cannot convert from 'bool' to 'int' C:\Users\Kyle\documents\visual studio 2010\Projects\Game 1\Game 1\Form2.cs  156 49  Game 1
Posted

if(Death.Location.X <=30)
{
   //your code goes here
}
 
Share this answer
 
This is because Death.Location.X <= 30 is boolean, but you need integer.
It does not seem you understand what do you want. You compare Death.Location with Death.Location and then assign Death.Location

—SA
 
Share this answer
 
Comments
Manas Bhardwaj 10-Mar-11 5:58am    
+5
Sergey Alexandrovich Kryukov 10-Mar-11 10:26am    
Thank you, Manas,
--SA
TimGameDev 10-Mar-11 6:33am    
This is meaningless but anyway, if OP wants to keep his "if" structure he can use something like this:
if (Death.Location == new Point((Death.Location.X <= 30)? NewValue : Death.Location.X, Death.Location.Y))
{
Death.Location = new Point(Death.Location.X - movement, Death.Location.Y);
}

But SA is right it seems like OP is a little bit confused with his idea. My 5
Sergey Alexandrovich Kryukov 10-Mar-11 10:33am    
Thank you, Timur,
You see, I think I tried to answer one question of OP long time ago. This is some game, object moves throw screen, with spherical topology: go out on right -- appears on left. This damn 30 -- width of it (always hard-coded!). And many-many questions on that motion... same mistakes of the same sort: how to read and assign current position. Now, can you imagine what happens with threading, invocation, rendering and control, is coordinate update is where you see it..?
--SA
TimGameDev 10-Mar-11 17:25pm    
Sounds like nightmare actually...I think that my only advice in that case would be - figure it out on paper first :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900