Jump to content
  • Advertisement

Herter

Member
  • Content Count

    14
  • Joined

  • Last visited

Community Reputation

127 Neutral

About Herter

  • Rank
    Member
  1. Herter

    XNA pathfinding

    The reason I'll probably implement a A* is because I'm going to create a level editor eventually and to have some weapon be able to manipulate the maps (collateral damage = destroy stones).. and I'd like the enemies to use this to find a better route.. I.e. a "smart" tower defense game :P
  2. Hi I'm trying to create a 2D Tower Defense game with XNA. Sofar I've done a tilemap with a path on it. The map is done with a multidimensional array and the path is a hardcoded 2d-array with coordinates. I've got an enemy to follow the path correctly, but I think I'm going down a silly path.. Is this a good way of implementing this - or is there a better way? The pathfinding will eventually be done with a A* implementation, but how would I do that on a multidim. array? - Would it be better to create a map based on a collection of tile objects a la List<Tile>? It just seems like a "heavier" solution, but might be more "flexible". Be gentle... I'm new to gamemaking :P
  3. Hi I'm trying to do some collision detections in 2D. I have a pong game where I need to check for the collisions between the ball and paddle. I've managed to use the BoundingBox to detect the collisions, but I need to know which sides collided such that I can bounce the ball in the correct direction. How to solve this? I've tried with alot of if-else's but I didnt get it to work. The big problem I have is that when the ball's speed is high it can "enter" the paddle before the collision is detected and then I really dont know how to check if it entered from the top or the side. The if-else's I've used sofar are these: //This is the check for the "side"-collision and it works perfectly if (ball.ballPosition.X <= player1.playerPaddle.paddlePosition.X + player1.playerPaddle.paddleTexture.Width && (ball.ballPosition.Y + ball.ballTexture.Height >= player1.playerPaddle.paddlePosition.Y && ball.ballPosition.Y <= player1.playerPaddle.paddlePosition.Y + player1.playerPaddle.paddleTexture.Height)) { ball.ballDirection = new Vector2(-ball.ballDirection.X, ball.ballDirection.Y); ball.ballSpeed += 0.1f; } //This is the check for the top-collision if (((ball.ballPosition.Y + ball.ballTexture.Height) <= player1.playerPaddle.paddlePosition.Y) && (ball.ballPosition.X <= (player1.playerPaddle.paddlePosition.X + player1.playerPaddle.paddleTexture.Width)) && (ball.ballPosition.Y >= (player1.playerPaddle.paddlePosition.Y - ball.ballTexture.Height)-2)) { ball.ballDirection = new Vector2(ball.ballDirection.X, -ball.ballDirection.Y); } else if (((ball.ballPosition.Y + ball.ballTexture.Height) <= player1.playerPaddle.paddlePosition.Y) && ((ball.ballPosition.X + ball.ballTexture.Width) >= player1.playerPaddle.paddlePosition.X) && (ball.ballPosition.X <= player1.playerPaddle.paddlePosition.X) && (ball.ballPosition.Y >= (player1.playerPaddle.paddlePosition.Y - ball.ballTexture.Height))) { ball.ballDirection = new Vector2(-ball.ballDirection.X, -ball.ballDirection.Y); } The checks work as following: side-collision: - Checks if the ball hits the paddle while they overlap on both X and Y axis top-collision: - Checks if the ball hits the paddle while overlapping on both X and Y axis AND ??? this is where I dont know how to proceed Sorry if the code is unreadable.. Just ask if there is something that difficult to understand. Just a note.. I'm not looking for a complete solution, just a pointer in the right direction of how to solve this puzzle.. Thanks in advance
  4. I'm not a very experienced programmer, but I think that it depends on what you prefer.. I never name my variables identically to the types, but if you dont have a problem with distiguishing between them then why change it? I always have variable in lower-case only and types are Uppercase (the first letter only though)
  5. Thank you, it worked perfectly :) Forgot to mention that I use the XNA framework so the framerate is already fixed. :)
  6. Hi I've created a simple 2d pong game in C#. However, i'm having a little problem with calculating the ball speed.. when a ball is created it is positioned in the middle of the window and then the direction is random. Code for the ball creation is here: protected void createBall() { ball = new Ball(2.0f, createBallDirection()); ball.ballTexture = Content.Load<Texture2D>("ball"); ball.ballPosition = new Vector2(graphics.GraphicsDevice.Viewport.Width / 2, graphics.GraphicsDevice.Viewport.Height / 2); } createBallDirection() returns a Vector2 where X and Y are random numbers between -5 and 5. In my game loop I calculate the new position like this: ball.ballPosition += ball.ballSpeed * ball.ballDirection; ball.ballPosition is a Vector2 and ball.ballSpeed is a float. The problem is then that the ball speed varies based on the direction.. f.eks. if the direction vector is (2,-2) the ball will move a bit slowly, but if the direction vector is (5,1) it moves faster across the screen.. So I need help on thinking this one out.. I simply cannot get it to move equally fast at all directions.. Thank you in advance
  7. ok.. thanks This is still somewhat "hazy" in my mind.. Any chance you have some kind of source code I can look at? - Preferably in Java or at least in C-syntax
  8. Thanks for the link, but I've got the theory covered, but need help on the programming bit :)
  9. Hi I'm involved in a project of making a Nine Men's Morris game. We're about done making it playable for 2 player, but now its time for the more difficult part. We're going to implement an AI into the game and plan on using a Minimax algorithm. But how to we go about creating the search tree? - En detailed explanation and/or a pseudo-code example would be ideal, but anything will do :) Thanks in advance
  10. Hi I'm involved in a project of making a Nine Men's Morris game. We're about done making it playable for 2 player, but now its time for the more difficult part. We're going to implement an AI into the game and plan on using a Minimax algorithm. But how to we go about creating the search tree? - En detailed explanation and/or a pseudo-code example would be ideal, but anything will do :) Thanks in advance
  11. Herter

    Making a 2d racing game, but how?

    Yeah I thought DirectX wouldnt be necessary, but hey might aswell get used to it ;) But since I cant even get started I probably should start out more simple..
  12. Herter

    Making a 2d racing game, but how?

    anyone? any help would be very appreciated.. :)
  13. Herter

    Making a 2d racing game, but how?

    Thanks for the reply.. :) I've been looking into some directX (although I'll be switching to OpenGL). I've made a little blue screen with a triangle of vertices so I'm getting there.. ;) I'm also wondering if anyone could give a good tip on how to make this grid layout? How would you make a 2d? I simply have no idea how to begin..
  14. Hi there.. Long time reader, first time poster here :) Anyhoo.. I'm not all that new to programming, but very new to game programming and since I want to become a game programmer, well I joined this forum ;) I want to make my own little racing game in 2D, something in the line of Micromachines. I've previously made a little textbased adventure game in C++ and then in school we made a Blackjack game in C#. I'm planning on making it in C#, but C++ will do if thats recommended. My problem is that I'm kinda lost here and simply dont know where to go from here.. :/ I'm thinking that what I need is: 1. Make some sort of grid that is the game-world 2. Make some squares in the grid drivable and some not 3. Make a car that can drive on drivable squares and not on the non-drivable squares 4. Keep tweaking, tuning and adding features 5. Sell the game and become a gazillionaire 6. Realise point 5. is unrealistic and quit game programming (in case someone didnt notice only point 1-4 were serious ;)) So back to the main point.. Where do I go from here, what do I need to get started? Thanks in advance
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!