Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

100 Neutral

About Astra

  • Rank
  1. i've got member variables, xpos, ypos, zpos. Not sure what specifically i should change about the way i've accessed the variables? also with the code you suggested, as i've seen in many tutorials - i dont understand AABB one and AABB two. Is this psudo code for my character1. and mainstage? or are there actual commands known as AABB? thanks for your patience
  2. Hi guys. I'm writing a 3D game, similar to Super Smash Bro's the characters only move along the X and Y axis, so I'm doing my collision detection only on the X and Y; and ignoring Z axis collisions. I tried implementing an AABB method of collision detection but I think I got it a bit wrong. I'm testing the min.x min.y of my character against the min.x min.y max.x max.y of the ''stage'' (that is, one big platform and 3 suspended platforms). So as you would expect only when the bottom left front corner (min) of my "character" rectangle goes into the platform does a collision occur. What I want to know is if there's a more efficient way of doing it than checking each individual vertex with the platform min/max. Heres the code for my collision function: void checkCollision() { if((Character1.min(0) > mainStage.min(0)) && (Character1.min(0) < mainStage.max(0)) && (Character1.min(1) > mainStage.min(1)) && (Character1.min(1) < mainStage.max(1))) { exit(0); } if((Character1.min(0) > platform1.min(0)) && (Character1.min(0) < platform1.max(0)) && (Character1.min(1) > platform1.min(1)) && (Character1.min(1) < platform1.max(1))) { exit(0); } if((Character1.min(0) > platform2.min(0)) && (Character1.min(0) < platform2.max(0)) && (Character1.min(1) > platform2.min(1)) && (Character1.min(1) < platform2.max(1))) { exit(0); } if((Character1.min(0) > platform3.min(0)) && (Character1.min(0) < platform3.max(0)) && (Character1.min(1) > platform3.min(1)) && (Character1.min(1) < platform3.max(1))) { exit(0); } } and in my character and platform class: float Character::min(int index) { float minimum[3] = {xpos-5.0f, ypos-10.0f, zpos-0.02f}; return minimum[index]; } float Character::max(int index) { float maximum[3] = {xpos+5.0f, ypos+10.0f, zpos+0.02f}; return maximum[index];} float Block::min(int index) { float minimum[3] = {getxCoords()-(getxWidth()/2), getyCoords()-(getyHeight()/2), getzCoords()-(getzLength()/2)}; return minimum[index]; } float Block::max(int index) { float maximum[3] = {getxCoords()+(getxWidth()/2), getyCoords()+(getyHeight()/2), getzCoords()+(getzLength()/2)}; return maximum[index]; } thanks for any advice
  3. thanks mate, was just missing the glEnable(GL_DEPTH_TEST) command
  4. Hi guys, I'm writing a 3d game, and my characters (two brown rectangles at the moment) are showing up in front of all other objects. Their Z value is 8.85, and the front and back values of the stage are 8.7 and 9.0. So i would assume my characters would go ''through'' the stage when i move them down or up, but they appear in front as though they are closest to the screen. Here are my files I'd appreciate any input: main.cpp http://pastebin.com/TLnLF5Le main.h http://pastebin.com/UPheJgAa keyboard.cpp http://pastebin.com/ntJ2AF62 keyboard.h http://pastebin.com/U0B0Vwnt character.cpp http://pastebin.com/2fjQWYXp character.h http://pastebin.com/QmXwKiug thank you
  5. ah, how stupid of me I had it in a different section works beautifully now thanks. sorry to have bothered you with such a small issue!
  6. ahh Ok of course. So now I've got: void idle() { if(keyStates['w']) Character1.setyCoords(Character1.ypos+1); if(keyStates['a']) Character1.setxCoords(Character1.xpos-1); if(keyStates['s']) Character1.setyCoords(Character1.ypos-1); if(keyStates['d']) Character1.setxCoords(Character1.xpos+1); if(skeyStates[GLUT_KEY_UP]) Character1.setyCoords(Character1.ypos+1); if(skeyStates[GLUT_KEY_LEFT]) Character1.setxCoords(Character1.xpos-1); if(skeyStates[GLUT_KEY_DOWN]) Character1.setyCoords(Character1.ypos-1); if(skeyStates[GLUT_KEY_RIGHT]) Character1.setxCoords(Character1.xpos+1); glutPostRedisplay(); } in my keyboard.cpp file and then in int main: // handle keyboard events glutKeyboardFunc(keyPressed); glutKeyboardUpFunc(keyUp); glutSpecialFunc(skeyPressed); glutSpecialUpFunc(skeyUp); glutIdleFunc(idle); but it still doesn't move the character around.. hmm, trying to think if i'm using incorrect scope or what else could have stopped it working
  7. So, once i've created this function I assume I should be creating it within keyboard.cpp so that I can use keyStates? do i want to simply call idle(); in my main function (in main.cpp) like this: // handle keyboard events idle(); glutKeyboardFunc(keyPressed); glutKeyboardUpFunc(keyUp); glutSpecialFunc(skeyPressed); glutSpecialUpFunc(skeyUp); Or must I have it in glutKeyboardFunc(idle); for it to register as a keyboard function? (although im assuming i dont want to do this for the reason you stated, it would only refresh with the key refresh speed) When i try writing the function in keyboard.cpp and calling it within my main function as idle(); it doesn't move the character when i run the program and press w or W. Sorry if i'm missing something obvious here. thanks
  8. perfect it's now working, thank you. I will spend the day trying to fix the other parts you guys mentioned and post here again if i really cannot figure it out. thanks again
  9. Hey, thanks for the reply. So i've moved this section out of display: Image* image = loadBMP("image0.bmp"); _textureId = loadTexture(image); delete image; image = loadBMP("image6.bmp"); _texture2Id = loadTexture(image); delete image; image = loadBMP("image13.bmp"); _texture3Id = loadTexture(image); delete image; image = loadBMP("image15.bmp"); _texture4Id = loadTexture(image); delete image; image = loadBMP("image6.bmp"); _texture5Id = loadTexture(image); delete image; image = loadBMP("image13.bmp"); _texture6Id = loadTexture(image); delete image; and put it just below where i have: GLuint _textureId; // openGL id of the texture GLuint _texture2Id; GLuint _texture3Id; GLuint _texture4Id; GLuint _texture5Id; GLuint _texture6Id; But i get loads of syntax errors now on each line with _textureId = loadTexture(image); ''expected constructor, destructor or type conversion before '=' operator" "expected ' or ; before '=' token" Any ideas? I mean it should work by just taking those parts out because they still load the images into those GLuint textureID's right? thanks
  10. Hi, thanks for your reply, which things specifically? the Lighting, the textures, anything else?
  11. Hi guys, i'm writing a 2d game, but when I run it and move my little rectangles around it is really laggy. I know that I need to take a big chunk out of my display() function and put it somewhere else but I'm not sure how much i can safely take out. my files are: main.cpp http://pastebin.com/92fjcd43 main.h http://pastebin.com/kBYXYTig keyboard.cpp http://pastebin.com/ahKCvbrC keyboard.h http://pastebin.com/KiqjWsLu bmpload.cpp http://pastebin.com/LANenLHQ bmpload.h http://pastebin.com/9iMLLjXc character.cpp http://pastebin.com/pnMXHqZB character.h http://pastebin.com/WcJuhjBm I would appreciate any advice on how i can get my game working smoothly. Thankyou
  12. thanks for the input guys, i'll upload my revised version in a minute
  13. Astra

    Issue with keypresses

    i solved my problem by just removing the keyOps and skeyOps and putting the key operations within keypressed and skeypressed under keyStates[key] = 1; etc thanks for the help
  14. posted in wrong section, sorry -> moved it to openGL
  • 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!