Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your feedback on a survey! Each completed response supports our community and gives you a chance to win a $25 Amazon gift card!


maximo1491

Member Since 29 Nov 2010
Offline Last Active Jul 25 2013 08:22 AM

Posts I've Made

In Topic: 2D grid based strategy engine

02 July 2013 - 11:16 AM

Thanks for the replies guys, and no it doesnt have to be C++ but I used it for the last couple of years at uni using DirectX and OpenGL just though that would be a good base, heard that SDL is pretty good do you guys recommend that? or go with c# and xna?


In Topic: Help with simple collision

29 November 2010 - 11:11 AM

Well this is the bit im having the trouble with. Basically when I run it, it is saying the other rectangle in the rectangle does not exist in current context. I've tried putting them both in the same class but the way the rest of my code is laid out I need them as two separate classes. Was just wondering if there is a way I can do this or do I have to restructure the rest of my code?

public class Warrior
{

public void Update(GameTime gameTime)
{

Rectangle warriorRectangle = new Rectangle((int)warriorPosition.X, (int)warriorPosition.Y, warriorTexture.Width, warriorTexture.Height);

warriorHit = false;

if (warriorRectangle.Intersects(enemyWarriorRectangle))
{
warriorHit = true;
}

if (warriorHit)
{
warriorPosition = new Vector2 (0,0);
}
}
}


public class enemyWarrior
{

public void Update(GameTime gameTime)
{

Rectangle enemyWarriorRectangle = new Rectangle((int)enemyWarriorPosition.X, (int)enemyWarriorPosition.Y, enemyWarriorTexture.Width, enemyWarriorTexture.Height);

enemyWarriorHit = false;

if (enemyWarriorRectangle.Intersects(warriorRectangle))
{
enemyWarriorHit = true;
}

if (enemyWarriorHit)
{
enemyWarriorPosition = new Vector2(0, 200);
}
}
}

[Edited by - maximo1491 on November 30, 2010 5:11:25 AM]

In Topic: Help with simple collision

29 November 2010 - 08:08 AM

Ok sorry im new to c# only started it about a month ago, what does that do?

In Topic: Ok I know im doing something wrong.... and its probably something simple

29 November 2010 - 05:07 AM

Ok thanks I really don't know why I was using two different classes that, yeah, were practically the same, merged them both together and getting the collisions working so thanks for your help.

PARTNERS