Jump to content
  • Advertisement

phil67rpg

Member
  • Content count

    1460
  • Joined

  • Last visited

Community Reputation

442 Neutral

1 Follower

About phil67rpg

  • Rank
    Contributor

Personal Information

  • Role
    Programmer
  • Interests
    Programming

Recent Profile Visitors

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

  1. phil67rpg

    blackjack game

    well I am making a text based blackjack game I am unsure of how to progress. here is the skeleton of my program. I am going to work on this more, and do some research on oop design. I don't want code. I am just trying to be a better programmer. I am also learning how to program in oop paradigm. #include <iostream> #include <time.h> using namespace std; enum suit { S, H, D, C }; enum face { J = 11, Q, K, A }; class card { private: public: }; class deck { private: public: }; int main() { system("pause"); return 0; }
  2. phil67rpg

    sprite movement

    well I ordered a book on sdl 2
  3. phil67rpg

    sprite movement

    I have also used sdl2 but I don't have any books for it yet.
  4. phil67rpg

    sprite movement

    void collision_bug_one(float x, float y) { glEnable(GL_TEXTURE_2D);//collision sprite glBindTexture(GL_TEXTURE_2D, _textureId_four); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glColor3f(1.0f, 1.0f, 1.0f); glBegin(GL_POLYGON); glTexCoord2f(0.0f, 0.0f); glVertex3f(x, y, 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f(x, y-1.0f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f(x+1.0f, y-1.0f, 0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(x+1.0f, y, 0.0f); glEnd(); glDisable(GL_TEXTURE_2D); } void collision(int value) { flag[0][0] = 1; glutTimerFunc(1000, collision, 5); } void coll_bug_one() { float x = -0.5f + scroll; float y = -8.0f + up; float oWidth = 0.5f; float oHeight = 0.5f; float xTwo = -2.0f; float yTwo = 9.0f; float oTwoWidth = 0.5f; float oTwoHeight = 0.5f; if (checkCollide(x, y, oWidth, oHeight, xTwo, yTwo, oTwoWidth, oTwoHeight) == 1) { collision_bug_one(-2.0f, 10.0f); Sleep(50); glutTimerFunc(25, collision, 5); } } void erase_sprite() { if (flag[0][0] == 1) { glColor3f(0.0f, 0.0f, 0.0f); glBegin(GL_POLYGON); glVertex3f(-2.0f, 10.0f, 0.0f); glVertex3f(-2.0f, 9.0f, 0.0f); glVertex3f(-1.0f, 9.0f, 0.0f); glVertex3f(-1.0f, 10.0f, 0.0f); glEnd(); } } void delay() { float velocity = 20.0f, init_position = 0.0f; static int prvMs = glutGet(GLUT_ELAPSED_TIME); drawScene_bug_two(position, 10.0f); const int curMs = glutGet(GLUT_ELAPSED_TIME); const double dt = (curMs - prvMs) / 1000.0; prvMs = curMs; position = velocity*dt + init_position; cout << position << endl; } void move(int v) { move_right++; if (move_right >= 9.0f) { move_right = 9.0f; } drawScene_bug_two(move_right, 10.0f); glutPostRedisplay(); glutTimerFunc(1000, move, 0); } void drawScene() { glClear(GL_COLOR_BUFFER_BIT); bullet(); drawScene_bug_one(-2.0f, 10.0f); move(0); glutTimerFunc(1000, move, 0); coll_bug_one(); erase_sprite(); drawScene_ship_one(); glutSwapBuffers(); } void shoot() { up += 0.5f; if (up >= 17.5f) { animate = 0; up = move_up; glutIdleFunc(NULL); } glutPostRedisplay(); } void handleKeypress(unsigned char key, int x, int y) { switch (key) { case 27: //Escape key exit(0); break; case 32: animate = !animate; if (animate) { glutIdleFunc(shoot); } else { glutIdleFunc(NULL); } break; } glutPostRedisplay(); } void handleSpecialKeypress(int key, int x, int y) { switch (key) { case GLUT_KEY_UP: move_up += 0.1f; break; case GLUT_KEY_DOWN: move_up -= 0.1f; if (move_up <= 0.0f) { move_up = 0.0f; } break; case GLUT_KEY_LEFT: scroll -= 0.1f; if (scroll <= -9.0f) { scroll = -9.0f; } break; case GLUT_KEY_RIGHT: scroll += 0.1f; if (scroll >= 9.0f) { scroll = 9.0f; } break; } glutPostRedisplay(); } void update(int value) { down -= 0.1f; if (down <= -20.0f) { down = 0.0f; } glutPostRedisplay(); glutTimerFunc(25, update, 0); } int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowPosition(500, 200); glutInitWindowSize(800, 600); glutCreateWindow("Bug Wars"); initRendering(); initRendering_two(); initRendering_three(); initRendering_four(); initRendering_five(); glutDisplayFunc(drawScene); glutTimerFunc(25, update, 0); // glutTimerFunc(1000, move, 5); glutKeyboardFunc(handleKeypress); glutSpecialFunc(handleSpecialKeypress); glutReshapeFunc(handleResize); glutMainLoop(); return 0; } well here is more of my code
  5. phil67rpg

    sprite movement

    well I have 8 pages of code and I think I have already posted the drawing portion of my game.
  6. phil67rpg

    sprite movement

    how do I determine my tick rate?
  7. phil67rpg

    sprite movement

    I am using fixed time step and using move_right++ to move the sprite but it moves too fast. also I want it to move one sprite width at a time. maybe I should use a variable time step.
  8. phil67rpg

    OpenGL sprite movement

    void move(int v) { move_right++; if (move_right >= 9.0f) { move_right = 9.0f; } drawScene_bug_two(move_right, 10.0f); glutPostRedisplay(); glutTimerFunc(1000, move, 0); } void drawScene() { glClear(GL_COLOR_BUFFER_BIT); bullet(); drawScene_bug_one(-2.0f, 10.0f); move(0); glutTimerFunc(1000, move, 0); coll_bug_one(); erase_sprite(); drawScene_ship_one(); glutSwapBuffers(); } well I am able to move a sprite from the center of the screen to the right. it however moves too quickly, I want it to move one sprite width to another, I also want to move slowly. I want it to move like in space invaders.
  9. phil67rpg

    wait loop

    well I finally solved my problem, thanks for all the help.
  10. phil67rpg

    wait loop

    void collision(int value) { board[0][0] = 1; glutPostRedisplay(); } void coll_bug_one() { float x = -0.5f + scroll; float y = -8.0f + up; float oWidth = 0.5f; float oHeight = 0.5f; float xTwo = 0.0f; float yTwo = 9.0f; float oTwoWidth = 0.5f; float oTwoHeight = 0.5f; if (checkCollide(x, y, oWidth, oHeight, xTwo, yTwo, oTwoWidth, oTwoHeight) == 1) { glutTimerFunc(1000, collision, 5); } } void coll_sprite() { if (board[0][0] == 1) { collision_bug_one(0.0f, 10.0f); glutTimerFunc(1000, collision, 5); // flag[0][0] = 1; } } void erase_sprite() { if (flag[0][0] == 1) { glColor3f(0.0f, 0.0f, 0.0f); glBegin(GL_POLYGON); glVertex3f(0.0f, 10.0f, 0.0f); glVertex3f(0.0f, 9.0f, 0.0f); glVertex3f(1.0f, 9.0f, 0.0f); glVertex3f(1.0f, 10.0f, 0.0f); glEnd(); } } I have made some progress, thanks rutin, I can draw a bug then hit it with a bullet and then it draws a collision sprite but I want it be drawn for a second and then I want it to be erased. I am close to solving my problem.
  11. phil67rpg

    wait loop

    I am sorry to ask but what do you mean by "frames"
  12. phil67rpg

    wait loop

    void collision(int v) { collision_bug_one(0.0f, 10.0f); glutPostRedisplay(); glutTimerFunc(1000, collision, 0); } void coll_sprite() { if (board[0][0] == 1) { collision(0); flag[0][0] = 1; } } void erase_sprite() { if (flag[0][0] == 1) { glColor3f(0.0f, 0.0f, 0.0f); glBegin(GL_POLYGON); glVertex3f(0.0f, 10.0f, 0.0f); glVertex3f(0.0f, 9.0f, 0.0f); glVertex3f(1.0f, 9.0f, 0.0f); glVertex3f(1.0f, 10.0f, 0.0f); glEnd(); } } I am using glutTimerFunc to wait a small amount of time to display a collision sprite before I black out the sprite. unfortunately my code only blacks out the said sprite without drawing the collision sprite, I have done a great deal of research on the glutTimerFunc and animation.
  13. phil67rpg

    Finding and Choosing Libraries for C++

    well I use opengl but there is also direct x
  14. phil67rpg

    checkers

    sorry but I am kind of slow when it comes to programming, I do make progress but it comes slowly to me.
  15. phil67rpg

    checkers

    well rutin I solved my problem, thanks for all the help
  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!