Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

122 Neutral

About SharQueDo

  • Rank
  1. SharQueDo

    [C++] OOP question

    Yes, thank you. :D
  2. I have a parent class called CObject which has a virtual void called Update(); class CObject { ... virtual void Update() = 0; ... } Next, I have a child class called OPlayer. class OPlayer : public CObject { ... } I want the Update() in CObject to preform some basic instructions, but I want the function Update() avaible in OPlayer too for additional instructions. How can I do this? void CObject::Update() { // basic instructions here } void OPlayer::Update() { // additional crap here }
  3. Okay, no error when compiling, but when I try to execute the program it quits with an error: Metroid Tournament.exe has encountered a problem and needs to close. We are sorry for the inconvenience. If you were in the middle of something, blah blah blah...
  4. I only declared it: class OPlayer : public CObject { public: // Constructor OPlayer(float nx, float ny, int nw, int nh, CSprite sprite); void Update(); // Update void Draw(); // Draw to screen }; When I include it too it gives me 8 errors saying: e:\metroid tournament\source\oplayer.h(29) : error C2512: 'CObject' : no appropriate default constructor available
  5. CSprite sprTiles[NUM_TILES - 1]; sprTiles[0].Load("data/gfx/tile1.png"); sprTiles[1].Load("data/gfx/tile2.png");
  6. Okay, I had this for line 42: OPlayer player(1,2,3,4,5); So that error was kinda logical. But now I changed it to this: OPlayer player(64,64,16,16,sprTiles[0]); And it gives me this error: --------------------Configuration: Metroid Tournament - Win32 Debug-------------------- Compiling... splay.cpp Linking... splay.obj : error LNK2001: unresolved external symbol "public: __thiscall OPlayer::OPlayer(float,float,int,int,class CSprite)" (??0OPlayer@@QAE@MMHHVCSprite@@@Z) Debug/Metroid Tournament.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe. Metroid Tournament.exe - 2 error(s), 0 warning(s)
  7. Hi! :D I have a class CSprite, which contains sprite data (SDL_Surface, Draw(x,y), etc). I have a class CObject, which functions as a parent class for objects (like player, projectile, destroyable terrain blocks, etc), and I have a child class OPlayer: class CObject { public: CObject(float nx, float ny, int nw, int nh, CSprite sprite) { x = nx; y = ny; w = nw; h = nh; m_sprite = sprite; }; virtual void Update() = 0; virtual void Draw() = 0; float x, y; int w, h; float velx, vely; CSprite m_sprite; }; class OPlayer : public CObject { public: OPlayer(float nx, float ny, int nw, int nh, CSprite sprite); void Update(); void Draw(); }; Now, I create the player class: CSprite sprSprite; sprSprite.Load("sprite.png"); OPlayer player(64, 64, 16, 16, sprSprite); It gives this error: --------------------Configuration: Metroid Tournament - Win32 Debug-------------------- Compiling... splay.cpp E:\Metroid Tournament\Source\splay.cpp(42) : error C2664: '__thiscall OPlayer::OPlayer(float,float,int,int,class CSprite)' : cannot convert parameter 5 from 'const int' to 'class CSprite' No constructor could take the source type, or constructor overload resolution was ambiguous Error executing cl.exe. Metroid Tournament.exe - 1 error(s), 0 warning(s) Can't I use classes in (child class) constructor parameters? What's wrong with this?
  8. SharQueDo

    Select source x,y,w,h

    That must be the most crappiest post ever... Any chance you would feel like posting a function about it here????
  9. Is it possible to have a 512x512 tilesheet and just draw eg tile 18 (starts at 64,32, ends at 96,64)?
  10. SharQueDo

    [2D] Doesn't draw texture

    DOH!! My texture wasn't in the power of 2 (16x16, 32x32, 64x64, etc), it was 15x15. Thnx guys. <D
  11. It's nice how people post a solution to their own awnser if they have figured it out themselves. 'Cus I need rotation too. Thnx. :)
  12. SharQueDo

    [2D] Doesn't draw texture

    I tried 24b and 8b BMPs, they were both loaded, but neither were blitted.
  13. SharQueDo

    [2D] Doesn't draw texture

    Doesn't work... :( Quick question: Do I need to free g_picture and g_picture->data? I saw that on NeHe's tuts, but when I try to free those the program just quits with an unknown error.
  14. Hi! :D I'm making a 2d game, and I want to use OpenGL. I want to load and draw a texture, but it doesn't draw the texture. It does draw the right image size (32x32size at 100x100location draws a 32x32 white square at 100x100), though. Initialization: glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0.0f, width, height, 0.0f, -1.0f, 1.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glShadeModel(GL_SMOOTH); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearDepth(1.0f); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); class CSprite { public: ... bool Load(const char *file); // Load sprite ... bool Draw(int x, int y); // Draw the sprite private: GLuint texture; // Texture data AUX_RGBImageRec *g_picture; // OGL image data }; bool CSprite::Load(const char *file) { g_picture = auxDIBImageLoad(file); glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); glTexImage2D(GL_TEXTURE_2D, 0, 4, g_picture->sizeX, g_picture->sizeY, 0, GL_RGBA, GL_UNSIGNED_BYTE, g_picture->data); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // Some debug info printf("Done loading %s\n", file); return true; } bool CSprite::Draw(int x, int y) { glTranslatef(x, y, 0.0f); glBindTexture(GL_TEXTURE_2D, texture); glBegin(GL_QUADS); glTexCoord2f(0,0); glVertex2d(0.0f, 0.0f); // top left glTexCoord2f(1,0); glVertex2d(g_picture->sizeX, 0.0f); // top right glTexCoord2f(1,1); glVertex2d(g_picture->sizeX, g_picture->sizeY); // bottom left glTexCoord2f(0,1); glVertex2d(0.0f, g_picture->sizeY); // bottom right glEnd(); return true; }
  15. SharQueDo

    Need help, spaceship physics

    Could someone explain to me/point me to a tutorial how Spaceship Physics work? I want to create a game with spaceships but I'm kinda stuck with the physics. Maybe a bit of source code that can help me understand. I want it really basic, just Thrust, Brake and turn 360° with some air friction when not thrusting. I'm kinda noob at maths and I would like to understand how such things as these work, so I can program such things myself next time. EDIT: I use C++ with the Allegro library. The game will be 2D.
  • 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!