Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

125 Neutral

About v0rtexza

  • Rank
  1. v0rtexza

    Best OpenGL books for beginners (C++)

    I purchased beginning opengl game programming, second edition and am reading the arcsynthesis online book while I wait for my book to arrive. The beginning opengl game programming book looks like it leaves a lot out which is understandable, what would be a good follow up book? I was thinking of more opengl game programming? Any other ideas is awesome. Thanks all!
  2. Hey all, I am interested as to what your takes are on what books to get for OpenGL programming? I want to buy a couple books so that I can learn 3D Game Programming with OpenGL in C++ however I am not sure as to what to get. I don't so much want a big reference book as much as I want a book that offers some direction in its text in terms of actual game programming and does not just act as a reference for experienced users. I have been looking at Beginning OpenGL Game Programming, second edition and was thinking that a second book I could buy would be More OpenGL Game Programming? The one query I have for anyone that has read More OpenGL Game Programming. Its publication date is 2006 whilst Beginning OpenGL Game Programming's publication date is 2009, will its information still be relevant? What do you all think about what book to get? Thanks, v0rtexza
  3. Nevermind, got it working with the following: I set a long variable to 0 that would hold the last time the player shot and then I did the following [source lang="cpp"] if ((int)timeGetTime() < lastShot + 100) return; else { //shoot bullet }[/source] Thanks everyone, for all your help!
  4. Sorry as an addendum to my last post (as I can't edit!?) After the second last bracket, I had: [source lang="cpp"]} } else keySpaceIsHeld = false; }[/source]
  5. Thanks fastcall22, I tried your first solution: [source lang="cpp"] if (Key_Down(DIK_SPACE)) { //limit firing rate // if (GetTickCount() - player_shoot_timer > 100) return; //player_shoot_timer = GetTickCount(); if (!keySpaceIsHeld) keySpaceIsHeld = true; if (keySpaceIsHeld) { if (CurrentBullet == MAX_BULLETS -1) return; //CurrentBullet = Max Ammo, So Exit if (CurrentBullet < MAX_BULLETS) //If there are bullets available { bullets[CurrentBullet].alive = true; bullets[CurrentBullet].x = player.x + (player.width/2); bullets[CurrentBullet].y = player.y; } } } [/source] But It still does what it did and increases CurrentBullet a lot instead of by 1 upon each keypress. Editing my windows code to work with my main code sounds like a massive hassle as I would have to rewrite ALOT of my code... Sorry to bother man, you've been a lot of help!
  6. Wow lol, was focusing so much on the graphics and DirectX that I forgot something as simple as that. Thanks! My only last problem is that I do not know how to space input, so that for example when you click space. Only 1 shot is registered, at the moment whenever space is held down, my variable CurrentBullet (as seen in the listing above) continually increases as much as I click instead of only registering one click. Any ideas?
  7. Hey all, I am making a simple sidescroller space shooter and have encountered a problem. I do not know how to limit the amount of bullets adequately or control the difference between input times. Here is the relevant code that I know is the problem. I create space in memory for my bullet sprites and I set their default properties (according to my own class): [source lang="cpp"]//bullet sprites const int MAX_BULLETS = 20; SPRITE bullets [MAX_BULLETS]; //set default properties for (int j = 0; j < MAX_BULLETS;j++) { bullets[j].alive = false; bullets[j].startframe = 0; bullets[j].endframe = 1; bullets[j].delay = 10; bullets[j].x = 0; bullets[j].y = 0; bullets[j].height = 55; bullets[j].width = 16; bullets[j].columns = 1; bullets[j].vely = 6.0f; } imgBullet = LoadTexture("purplefire.tga"); if (!imgBullet) return false; player_shoot_timer = 0;[/source] I then go onto set bullets to alive when I click space bar like so: [source lang="cpp"]if (Key_Down(DIK_SPACE)) { //limit firing rate if ((int)timeGetTime() < player_shoot_timer + 100) return; player_shoot_timer = timeGetTime(); if (CurrentBullet >= MAX_BULLETS) CurrentBullet = 0; CurrentBullet++; bullets[CurrentBullet].alive = true; bullets[CurrentBullet].x = player.x + (player.width/2); bullets[CurrentBullet].y = player.y; }[/source] But the above code is not adequately stopping me from shooting if I hold down for example space bar, any ideas on that? Finally in my actual game loop, I render the bullets that are deemed "alive" or have been shot already: [source lang="cpp"]for (int k = 0;k < MAX_BULLETS;k++) { if (bullets[k].isAlive() == true) { bullets[k].y -= bullets[k].vely; // Sprite_Animate(bullets[k].frame,bullets[k].startframe,bullets[k].endframe,1,bullets[k].starttime,bullets[k].delay); Sprite_Draw_Frame(imgBullet,bullets[k].x,bullets[k].y,bullets[k].frame,bullets[k].width,bullets[k].height,bullets[k].columns); } }[/source] However the problem is that I can hold down spacebar and it will just keep rendering the bullets to that spot and once I finish the program/close it, I get the following error: Unhandled exception at 0x61a659da (msvcr100d.dll) in Tile_Dynamic_Scroll.exe: 0xC0000005: Access violation reading location 0x4424aac2. I am guessing this is because I am not resetting the bullets adequately but I can't figure out: a) how to create a time between each fired bullet so that the user cannot spam spacebar, my current implementation does not work b) Limit the amount of bullets fired and reset them accordingly. (if any more code is needed, I will supply upon request as the entire project is largeish) I do not want the complete answer but merely a nudge in the right direction, any help is appreciated. Thanks, v0rtex
  • 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!