• Advertisement

maximo1491

Member
  • Content count

    7
  • Joined

  • Last visited

Community Reputation

103 Neutral

About maximo1491

  • Rank
    Newbie
  1. 2D grid based strategy engine

    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?
  2. Hey guys, I'm sure this question has been asked a hundred times before but after a quick look through the posts I cant really find anything, I recently participated in the Brains Eden game jam and afterwards I really just want to expand the game we made for it!   What I am wondering is if their is a 2D engine you can recommend for me to use or is it better to make my own one, which I am fine with just obviously there is no point doing it if there is a perfectly good tool already out there! The style of the game has an age of empires feel but will be a more modern day equivalent, the plan is to have quite a big map so obviously when all the AI and pathfinding come into play some performance problems could be an issue! Any suggestions you guys have would be much appreciated!   EDIT: Obviously didnt look very hard just found this in the beginner section, would rather build this game in C++ as well which I forgot to mention but have got experience in C# and js!
  3. Help with simple collision

    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]
  4. Help with simple collision

    Ok sorry im new to c# only started it about a month ago, what does that do?
  5. Help with simple collision

    Basically im trying to do a rectangle collision so if rectangle intersects with blah blah then do this, but im trying to do this between two separate classes so when I run the code it is saying that it does not exist in current context because im guessing that the rectangle im trying to intersect it with is in the other class therefore not knowing where it is, is there a way I can get it to detect the rectangle in the other class?
  6. 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.
  7. Ok so im trying to get two objects to collide with each other and for now just to move them to a different position so that I know that the collision is working I can sort the rest out after the collisions are confirmed. Im getting 2 CS0103 error - "The name 'enemyWarriorRectangle' does not exist in current context" and "The name 'warriorRectangle' does not exist in current context". Basically I just want to know how I can fix this problem and any help is much appreciated. This is not the entire code but im assuming the issue is coming from the classes themselves rather than the actual game although if I am mistaken I can post the rest of the code. public class Warrior { public Vector2 warriorPosition = new Vector2(250, 500); public Vector2 warriorSpeed = new Vector2(1f, 0f); public static Texture2D warriorTexture; public bool warriorExists = true; public bool warriorHit; public Warrior() { } public void Update(GameTime gameTime) { warriorPosition.X += warriorSpeed.X; 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 void Draw(SpriteBatch spriteBatch) { spriteBatch.Begin(); spriteBatch.Draw(warriorTexture, warriorPosition, null, Color.Blue, 0,new Vector2(0, 0), 0.3f, SpriteEffects.None,0); spriteBatch.End(); } } public class enemyWarrior { public Vector2 enemyWarriorPosition = new Vector2(1250, 500); public Vector2 enemyWarriorSpeed = new Vector2(-1f, 0f); public static Texture2D enemyWarriorTexture; public bool enemyWarriorExists = true; public bool enemyWarriorHit; public enemyWarrior() { } public void Update(GameTime gameTime) { enemyWarriorPosition.X += enemyWarriorSpeed.X; 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); } } public void Draw(SpriteBatch spriteBatch) { spriteBatch.Begin(); spriteBatch.Draw(enemyWarriorTexture, enemyWarriorPosition, null, Color.Red, 0, new Vector2(0, 0), 0.3f, SpriteEffects.FlipHorizontally, 0); spriteBatch.End(); } }
  • Advertisement