Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

116 Neutral

About neomaycry

  • Rank
  1. I am working on a space shooter game, using SFML and c++.  My game has an enemy that flies to the center of the screen and shoots a laser which rotates 360 degrees.  Everything about this process looks great except one fact: the laser needs to be "clipped" when it encounters a tile (so the player can hide behind the tile to avoid it). Take a look at the following image:   [attachment=16964:laserball.png]   Also, here is the code I have written: for(int i=0;i<numBlocks;i++) for(int j=0;j<numEnemies;j++) if(Collision::BoundingBoxTest(block[i].sprite, enemy[j].laser) && block[i].alive && enemy[j].alive && enemy[j].id == LASERBALL) { std::cout << "Laser collided with tile!" << std::endl; enemy[j].laserCollidedWithTile = true; enemy[j].laser.setScale(laserW * (block[i].sprite.getPosition().x / enemy[j].sprite.getGlobalBounds().width), 1); //fix this } The collision itself is working fine.  The problem I am having is figuring out the math of how to scale the laser so it appears to be blocked by the tile.  I've also considered approaching this problem by resizing the sprite's textureRect.  If you have time, I would appreciate feedback regarding my approach and how to fix it.  Remember that the laser is a rotated object.   EDIT: 'laserW' is a global variable used for testing purposes.  It contains the width of the laser sprite, which is 1060px.
  2. neomaycry

    Smooth Sprite Movement

    Servant,   Your explanation was superb, and the resources you shared are wonderful.  Everything looks beautiful now.  Delta time was the answer :).   Thank you!
  3. neomaycry

    Smooth Sprite Movement

    I am continuing work on a 'space shooter' game in SFML 2.0, and everything is going well.  The question I have pertains to changing the sprite's position using velocity along the 'x' axis (velX) and velocity along the 'y' axis (velY).  Assuming each variable is set to a constant value of 5, the sprite will "skip" pixels until it reaches a new destination equal to its current position plus 5 per game cycle.   This creates a rough effect, as the sprite apparently jumps from one position along a diagonal line to the next.  Is there a way to have the game loop render all the "missing" frames between the sprite's old position and its new destination?  This is mostly a cosmetic concern.  The current method looks okay ... I just want to see if there is a "smoother" way of rendering the sprite's position change.   Thanks.
  4. These responses are exactly what I was looking for, and they've helped me develop my understanding of the design process. Presently, I've been designing features in a sandbox-type environment, and I just wanted to make sure that was the proper approach. It looks like it is. Thanks for the help!
  5. I am a new programmer with novice to intermediate experience with C++. I am currently working with SFML 2.0 and feel I have a good grasp of the system. My first project is a space shooter game, and I currently have the following items coded and functional: 1) Player movement, collision, firing mechanism 2) Enemies (2 types, one that chases the player and fires; one that moves to the center of the screen and fires a laser in a 360 degree motion until the player kills it) 3) A tile map system that reads text files and loads images from a local resources folder 4) Scrolling backgrounds My question is this: If I plan on implementing many more enemy types and player features (i.e. power-ups, skill trees, etc.), how much of this should I design (code-wise) before building my first level? I definitely don't want to make a level and have to go back and change it all when I'm further into development. Likewise, I don't enjoy programming endlessly without "seeing" any sort of payoff. When should I move on to the next step? Thanks for your advice.
  • 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!