• Advertisement
Sign in to follow this  

weird error

This topic is 4617 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

class PLAYER
{
      public:
             SDL_Surface *img;
             float x, y, xv, yv;
             bool  jump, shoot;
             int   gun;
             float delay;
             
             static const float mv = 200;  // movement velocity
             static const float ac = 800;  // acceleration constant
             static const float jv = 400;  // jump velocity
             
             PLAYER();
             void event();
             void step();
             void draw();
};
for those lines it gives me the errors:
36 player.h local class `class drawLine(int, int, int, int, unsigned  int, SDL_Surface*)::PLAYER' shall not have static data member `float  
37 player.h local class `class drawLine(int, int, int, int, unsigned  int, SDL_Surface*)::PLAYER' shall not have static data member `float  
38 player.h local class `class drawLine(int, int, int, int, unsigned  int, SDL_Surface*)::PLAYER' shall not have static data member `float  
36 Dplayer.h field `drawLine(int, int, int, int, unsigned int,  SDL_Surface*)::PLAYER::mv' in local class cannot be static 
37 Dplayer.h field `drawLine(int, int, int, int, unsigned int,  SDL_Surface*)::PLAYER::ac' in local class cannot be static 
39 Dplayer.h field `drawLine(int, int, int, int, unsigned int,  SDL_Surface*)::PLAYER::jv' in local class cannot be static
and drawLine is defined in draw.cpp, and draw.h
//draw.cpp
void drawLine(int x1, int y1, int x2, int y2, Uint32 color, SDL_Surface* surf)
{      
	int deltax, deltay, signx, signy;
	int pixx, pixy;
	int x = 0, y = 0;
	int swaptmp;
	Uint8 *pixel;
	Uint8 *colorptr;

	deltax = x2 - x1;
	deltay = y2 - y1;
	signx = (deltax < 0) ? -1 : 1;
	signy = (deltay < 0) ? -1 : 1;
	deltax = signx * deltax + 1;
	deltay = signy * deltay + 1;

	pixx = surf->format->BytesPerPixel;
	pixy = surf->pitch;
	pixel = ((Uint8*)surf->pixels) + pixx * x1 + pixy * y1;

	pixx *= signx;
	pixy *= signy;
	if(deltax < deltay) // swap axis if rise > run
	{
		swaptmp = deltax; deltax = deltay; deltay = swaptmp;
		swaptmp = pixx; pixx = pixy; pixy = swaptmp;
	}

	switch(surf->format->BytesPerPixel)
	{
	case 1:
		for(; x < deltax; x++, pixel += pixx) {
			*pixel = (Uint8)color;
			y += deltay; if(y >= deltax) {y -= deltax; pixel += pixy;}
		}break;
	case 2:
		for(; x < deltax; x++, pixel += pixx) {
			*(Uint16*)pixel = (Uint16)color;
			y += deltay; if(y >= deltax) {y -= deltax; pixel += pixy;}
		}break;
	case 3:
		if(SDL_BYTEORDER == SDL_BIG_ENDIAN) color <<= 8;
		colorptr = (Uint8*)&color;
		for(; x < deltax; x++, pixel += pixx) {
			pixel[0] = colorptr[0];
			pixel[1] = colorptr[1];
			pixel[2] = colorptr[2];
			y += deltay; if(y >= deltax) {y -= deltax; pixel += pixy;}
		}break;
	default: //case 4
		for(; x < deltax; x++, pixel += pixx) {
	        *(Uint32*)pixel = (Uint32)color;
			y += deltay; if(y >= deltax) {y -= deltax; pixel += pixy;}
		}break;
	}
}
//draw.h
void drawLine(int x1, int y1, int x2, int y2, Uint32 color = 0, SDL_Surface* surf = scr)


i dont understand how these variables at all related to drawLine, when nothing else is??

Share this post


Link to post
Share on other sites
Advertisement
class Foo
{
static Bar baz;
};

// ...

Bar Foo::baz = 42; // Note: Don't stick this in a header.





Also, I think you might be missing a semicolon or something somewhere.

Share this post


Link to post
Share on other sites
hahaha....yah...

look at draw.h....
i forgot a semi-colin after the prototype...

heheh.. stupid errors couldn't tell me that..instead they give crazy stuff :
however, now im getting linker errors about those static variables. i'll try what you said

it worked :) feel free to delete this thread.
thanks for your help

[Edited by - darkzerox on June 1, 2005 2:39:19 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement