Hi guys,
Yesterday I've changed something in my program and didnt debug before I closed it. What's wrong about the CTile::GetTypeID()- function? I dont know anymore what exactly I changed, but I'm certain that I havn't changed that function...
#0 00405B10 CTile::GetTypeID(this=0x5244)
#1 00404397 CMap::GetTypeOfTile(this=0x4851f4, X=3, Y=5)
#2 00404963 CPlayer::Collision_Hor(this=0x485158, x=100, y=183, TileCoordY=@0x28fbdc: 5, Map=0x4851f4)
#3 004051FE CPlayer::Update(this=0x485158, Map=0x4851f4)
#4 00401E8E CGame::OnUpdate(this=0x485120)
#5 004021A1 SDL_main(argc=argc@entry=1, argv=argv@entry=0x330008)
#6 0040667C console_main(argc=argc@entry=1, argv=argv@entry=0x330008)
#7 0040683D WinMain@16(hInst=0x400000, hPrev=0x0, szCmdLine=0x7341d9 "",
#8 0047786B main () (??:??)
Again I think all of the Errors are coming from the GetTypeID()-function, which is being used in CMap::GetTypeOfTile(). CMap::GetTypeOfTile() is used in CPlayer::Collision_Hor() and so on...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
#ifndef _CTILE_H_
#define _CTILE_H_
#include "SDL.h"
#include "SDL_image.h"
#include <iostream>
#include "CSprite.h"
enum {TILE_TYPE_NONE = 0,
TILE_TYPE_SOLID = 1,
TILE_TYPE_WALKABLE = 2,
TILE_TYPE_DMG = 3,
TILE_TYPE_CLIMBABLE = 4,
TILE_TYPE_UNDERWATER = 5,
TILE_TYPE_COLLECTABLE = 6};
class CTile
{
public:
CTile();
int TempTileID;
int TempTypeID;
int GetTileID();
int GetTypeID();
int GetSize();
void Animate();
bool IsOnScreen(int X, int Y);
int GetCurrentFrame() { return CurrentFrame; }
private:
int TileID;
int TypeID;
int CurrentFrame;
static const int TILE_SIZE = 32;
};
#endif // _CTILE_H_
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
#include "CTile.h"
#include "CCamera.h"
CTile::CTile()
{
TileID = 0;
TypeID = TILE_TYPE_NONE;
CurrentFrame = 0;
}
int CTile::GetSize()
{
return TILE_SIZE;
}
int CTile::GetTileID()
{
return TileID;
}
int CTile::GetTypeID()
{
return TypeID;
}
bool CTile::IsOnScreen(int X, int Y)
{
TileID = TempTileID;
TypeID = TempTypeID;
if (X + TILE_SIZE >= CCamera::Camera.Viewport.x &&
X <= CCamera::Camera.Viewport.x + CCamera::Camera.Viewport.w &&
Y + TILE_SIZE >= CCamera::Camera.Viewport.y &&
Y <= CCamera::Camera.Viewport.y + CCamera::Camera.Viewport.h)
{
return true;
}
else
{
return false;
}
}
void CTile::Animate()
{
if (CurrentFrame <= 4)
{
CurrentFrame++;
}
else
{
CurrentFrame = 0;
}
}
|