Jump to content

C++ functions from other class


DarthRaff
 Share

Recommended Posts

Hello,

 

trying some simple collision but have problem when i try to use a class functions inside another class.

This are the pieces of code :

 

.h :

#include "elementograf.h"
#include "nivel.h"
class Prota : public ElementoGraf
{
   public:
    Prota();
    void moverDerecha(Nivel n);
    void moverIzquierda(Nivel n);
						    .
						    .
						    .
}

.cpp:

#include "elementograf.h"
#include "prota.h"
#include "nivel.h"
void Prota::moverDerecha(Nivel n)
{
   if (n.esPosibleMover(posX+4, posY, posX+anchura+4, posY+altura))
   {
    posX += 4;
   }
}
void Prota::moverIzquierda(Nivel)
{
   if (n.esPosibleMover(posX+4, posY, posX+anchura+4, posY+altura))
   {
    posX -= 4;
   }
}

 

in main :

 

void comprobarTeclas()
{
   if(hard.comprobarTecla(TECLA_ESC))
   {
    partidaTerminada = true;
   }
   if(hard.comprobarTecla(TECLA_DER))
   {
    prota->moverDerecha(Nivel n); // error: expected primary-expression before "n"
   }
   if(hard.comprobarTecla(TECLA_IZQ))
   {
    prota->moverIzquierda(Nivel n);// error: expected primary-expression before "n"
   }
}

 

Don't know what am i missing, can someone help me, please ? Thankyou

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...