Jump to content
  • Advertisement

Daniel Vellucci

Member
  • Content Count

    28
  • Joined

  • Last visited

Community Reputation

164 Neutral

About Daniel Vellucci

  • Rank
    Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Daniel Vellucci

    How to use xmlparser to load tmx maps?

      Since tmxparser is not a header-only library, the approach you just described would not work.   Building and using tmxparser is very much like building and using any other library that uses CMake as its build system. Also, you need working installations of zlib and TinyXML. - Build and install the library with CMake; - #include the appropriate header files (test/test.cpp is a good starting point) in your code; - Link your project against the appropriate import library that was built in step #1; - Profit.   sfml-tmxloader also uses CMake, and has an examples folder in the source tree. So it should be trivial to build it and link it to your project.   And if you're having trouble with these instructions, well, it's something you just have to live with when developing with C++: you have to learn the language AND understand the compilation process AND have a working knowledge of build systems, since not all libraries offer binary downloads.   Then before I go into my game I'm going to learn all this. Thanks a lot. 
  2. Daniel Vellucci

    How to use xmlparser to load tmx maps?

    Ok thanks for those links. The thing is I'm having trouble actually linking it to my project. I doubt I just put the files with my project and do a #include. Am I wrong in saying that?
  3. Apparently its very easy to do this which makes this pretty discouraging, but I'm just plain confused.   I'm making a Platformer with SFML/Box2D and c++ and want to know how I can use xmlparser to load a tmx map from Tiled. Whats confusing  me more than actually using tmxparser code is linking it to my project.   How do I get xmlparser to actually work with my project? Can someone give me a step by step guideline?   Also, after I do get xmlparser working and I actually get a tmx map on the screen, how do I use Box2D so that the tiles that have collision actually collide with my character?    
  4. Daniel Vellucci

    Rotating a sprite in SDL2?

    Can anyone that has ever done this please share how to do it? I'm looking at the LazyFoo tutorials and that code isn't working for me (using SDL_RenderCopyEx doesn't even draw the sprite). I want to rotate a sprite in real time based on where a specific object is. Is SDL even capable of doing this?
  5. Daniel Vellucci

    Enemy Bullets

      Well, we don't have any code to help, but I bet you can work it out.   Where is your timer variable stored?  It should be an EnemyShip class member variable since each ship should have it's own refire timer.  You don't have it as a global variable do you?   Go though your code, ask yourself what happens.  Try debugging and see why this is happening.  Good luck.   The code is pretty much what I posted earlier in the thread. If you look at one of the functions theres a part of it thats commented out. That one has a timer and when I use that ships fire one at a time like i explained.    I'm going to really go through the code like you said though. Its just that it seems like its something that should be done so easily.    No, that's only the function that acts on the "timer"  My question was, where is the timer variable stored?  Is it a global?  That's the code I want to see.   It should be a member variable for in each instance of class you have.   The Timer variables are just stored in the EnemyShip class. I initialize it as currentTime = SDL_GetTicks() and lastTime is initialized to zero.  void Enemy1Bullet::EnemyBulletHandler(int posX, int posY) { currentTime = SDL_GetTicks(); if(currentTime > lastTime + 1000) { Enemy1Bullet* bullet = new Enemy1Bullet(); bullet->box.x = posX + 50; bullet->box.y = posY + 35; enemyBullets.push_back(bullet); lastTime = currentTime; } }
  6. Daniel Vellucci

    Enemy Bullets

    And to the other people about sound, I'm not sure I'm even going to have the enemy ships have a sound effect. I might just have music instead. 
  7. Daniel Vellucci

    Enemy Bullets

      Well, we don't have any code to help, but I bet you can work it out.   Where is your timer variable stored?  It should be an EnemyShip class member variable since each ship should have it's own refire timer.  You don't have it as a global variable do you?   Go though your code, ask yourself what happens.  Try debugging and see why this is happening.  Good luck.   The code is pretty much what I posted earlier in the thread. If you look at one of the functions theres a part of it thats commented out. That one has a timer and when I use that ships fire one at a time like i explained.    I'm going to really go through the code like you said though. Its just that it seems like its something that should be done so easily. 
  8. Daniel Vellucci

    Enemy Bullets

    Okay well before I said that when I included a timer all my enemies would not shoot. Now I got them to shoot on a timer but only one shoots at a time.  So one enemy comes out and it shoots, when that enemy gets destroyed the next one in the vector shoots. 
  9. Daniel Vellucci

    Enemy Bullets

    Thanks for the advice. In your example, what does the update() method do? I see a lot of examples with it and I never understood what it was for.
  10. Daniel Vellucci

    Enemy Bullets

    At the moment this is what I have.      This is what I use to create the enemy bullets. The problem I have with this is when I add a timer to it, bullets don't get drawn at all. If I don't have a timer then enemies shoot a million bullets a second.  void Enemy1Bullet::EnemyBulletHandler(SDL_Renderer* ren, int posX, int posY) { /*currentTime = SDL_GetTicks(); if(currentTime > lastTime + 1000) { Enemy1Bullet* bullet = new Enemy1Bullet(); bullet->box.x = posX + 50; bullet->box.y = posY + 35; enemyBullets.push_back(bullet); lastTime = currentTime; }*/ Enemy1Bullet* bullet = new Enemy1Bullet(); bullet->box.x = posX + 50; bullet->box.y = posY + 35; enemyBullets.push_back(bullet); } This is to draw/move the bullets void Enemy1Bullet::DrawBullets(SDL_Renderer* ren) { for(int i = 0; i < enemyBullets.size(); i++) { enemyBullets[i]->DrawBullet(enemyLaser, ren, enemyBullets[i]->box.x, enemyBullets[i]->box.y); enemyBullets[i]->MoveBullet(); if(enemyBullets[i]->box.x < -80) { delete enemyBullets[i]; enemyBullets.erase(enemyBullets.begin() + i); i--; } } } In the enemy class I call the enemybulletHandler and the draw function for the bullets: void EnemyShip1::DrawEnemies(SDL_Renderer* ren, Enemy1Bullet& stuff) { //add enemies to the vector, loops through vector and draw EnemyHandler(); for(unsigned int i = 0; i < enemies.size(); i++) { enemies[i]->DrawEnemyTexture(enemy1Texture, ren, enemies[i]->box.x, enemies[i]->box.y); enemies[i]->MoveEnemy(); enemies[i]->Shoot(ren, enemies[i]->box.x, enemies[i]->box.y, stuff); //calls EnemyBulletHandler stuff.DrawBullets(ren); if(enemies[i]->box.x < -80) { delete enemies[i]; enemies.erase(enemies.begin() + i); i--; } } }
  11. Daniel Vellucci

    Enemy Bullets

    Is it siimilar to:   Loop through enemy enemy.createBullet();    I have something like this but it doesnt really work. 
  12. Daniel Vellucci

    Enemy Bullets

    What I mean is how do I create and store bullets? I got the player to shoot perfectly. For the player I just used a vector to store the bullets. But now I'm dealing with numerous enemies so how would I go about it?
  13. Daniel Vellucci

    Enemy Bullets

    I'm just a little confused at the moment. I'm making a 2d space shooter with SDL and C++. Whats the general process for making the enemies on screen shoot? How should I go about creating bullets for them?
  14. Daniel Vellucci

    Making Enemies shoot bullets

    Thanks everyone for advice. I'm going to take my time with this. Like someone said I do want it so when I implement collision its not a hassle. 
  15. Daniel Vellucci

    Making Enemies shoot bullets

    Thanks, ill try this out. My game is a simple shooter so they just have to shoot when they appear on screen.
  • 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!