Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

142 Neutral

About alejandro

  • Rank
  1. alejandro

    Collision Detection

    struct Rect { float x, y; float w, h; // true means there's a collision bool checkCollision(Ball & ball) { return ball.x > x && ball.x < x + w && ball.y > y && ball < y + w } }; struct Ball { float x, y; float w, h; float dir_x, dir_y; }; Rect paddle; Ball ball; void display(void) { if(paddle.checkCollision(ball)) { ball.dir_x *= -ball.dir_x; } } This may work :)
  2. Movement behaviour is a common topic on any AI for games  book, you can check this oune out: http://books.google.com.mx/books/about/Artificial_intelligence_for_games.html?id=1OJ8EhvuPXAC&redir_esc=y
  3. alejandro

    Game Architecture/Design Pattern?

    As i see, there's no best pattern... though I like to use managers since it's easier to me to read the code like this.
  4. alejandro

    Game Architecture/Design Pattern?

    Thank you very mucho for all your comments, I liked the idea on Performance vs Maintainability, also because a lot of the code I do is also read by other team members so it's important to have maintanable code   I'll take a look at the Game Engine book   Until know there's no clear best one, it appears as everyone has different approaches, that's what I am searching, how people create the architecture of the code.   Does anyone has an example on how MVC pattern will work in a videogame? particulary on Unity
  5. Hello,   I want to know if there are any game architectures that are recommended, well, actually I don't know if I can call them architectures or design patterns.   Basically what I want to know is how do you structure your games at a logical for example I tend to the following.   I create an object named GameMaster, this object controls the game (enemies, ambient, etc) and knows the state of everything in the game, the control is done through Managers, for example EnemieManager, AmbientManager, etc. This managers don't communicate directly, the communication has to go throught the GameMaster.   In a more plactical way say we have the following:   class GameMaster { Player player; EnemyManager enemyManager; GameStatus status; void update() { if(enemyManager.enemies == 0) { status = GameStatus.EndGame; } if(status == GameStatus.EndGame) { player.stopInteraction(); } } void draw() { drawString(status); } }   Sure, the managers can also have control of a few elements... what I see in some friends code is more like...   class Player { GameStatus status; void update() { if(status == GameStatus.EndGame) { player.stopInteraction(); } } void draw()     {          drawString(status);     } } class EnemiesManager { Player player; int enemies; void update() { if(enemies == 0) { player.status = GameStatus.EndGame; } } } So my doubt are, what is better? what is worse? are there any architecture/patterns for structuring the objects in the videogames?.   I follow the GameMaster pattern because it's easier to me to structure things like this, but maybe this is not the best pattern...     Any literature on the topic is appreaciated
  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!