예제 #1
0
void CTestGame::Init()
{
    CGame::Init();

    SetCaption("Test Game");
    mouse->SetVisible(false);

    //create game space
    SDL_Rect bounds;
    bounds.x = 0;
    bounds.y = 0;
    bounds.w = GetScreenWidth();
    bounds.h = GetScreenHeight();
    space = new CEntitySpace(bounds);

    //create entity
    CSurface* surf = CSurface::Load("smile.png");
    surf->SetColorKey(255,0,106);
    entity = new CEntity(surf,10.0,false);
    entity->position.x = entity->GetWidth()/2;
    entity->position.y = entity->GetHeight()/2;

    space->Add(entity);

    //create segments
    seg = new CSegment(SDL_MapRGB(Display_Surface->GetSDLSurface()->format,
                                            0,0,0));
    seg->v1.x = 0;
    seg->v1.y = 500;
    seg->v2.x = 500;
    seg->v2.y = 500;

    space->Add(seg);
}
예제 #2
0
파일: NOXMAP.cpp 프로젝트: elitak/NoxTools
bool NOX_MAP::AddTile(char objName[], int X, int Y, int variation)
{
	if( X < 0 || X > 255 ||
		Y < 0 || Y > 255)
		return(false);
	int ObjNum=0;
	ROLF *tile = NULL;
	for(tile = Thing.Thing.Tile.Tiles.Get(); tile && strcmp(tile->Name,objName); tile = Thing.Thing.Tile.Tiles.Get(), ObjNum++);
	Thing.Thing.Tile.Tiles.ClearGet();

	if( tile == NULL )
		return false;
	IDX_DB::Entry * Entry = NULL;
	IDX_DB::SectionHeader * Section = NULL;
	CSurface * surf;
    SURFACE tem;
	SURFACE * test;
	
		unsigned int val = *tile->Images.Get(variation); 
		tile->Images.ClearGet();
		val++;

test = Floor.TileImgs.Find(val);
if( !test )
{
	surf = NULL;
    fstream file;
	file.open(Video.bagpath,ios::in | ios::binary);
		Video.idx.GetAll(val,&Entry,&Section);
		
		if( Entry )
		{
		
			NxImage *img = Video.Extract(&file,Section,Entry);
			Display.Display->CreateSurface(&surf,img->width,img->height);
			if(surf)
				surf->SetColorKey(RGB(248,7,248));
			Display.BltBitmapData(img->data,img->width,img->height,surf->GetDDrawSurface());
			tem.surface = surf;
			tem.Height = img->height;
			tem.Width = img->width;
			tem.Image_ID = val;
			tem.ImgType = Entry->Entry_Type;
			tem.OffsetX = Entry->OffsetX;
			tem.OffsetY = Entry->OffsetY;
			img->Unload();
		}


		//LOAD THE NAME AS WELL NOW!!!!!
		Floor.TileImgs.Add(tem,val);    
		file.close();
		Floor.tileMap[X][Y].pTile = &Floor.TileImgs.last->msg;
}
else
{
  Floor.tileMap[X][Y].pTile = test;
}
		Floor.tileMap[X][Y].Tile = ObjNum;
		Floor.tileMap[X][Y].tVari = variation;
		Floor.tileMap[X][Y].TileImg = val;
		Floor.TileImgs.ClearGet();
	
		tem.surface = NULL;
		tem.name = NULL;
		surf = NULL;


return(true);
}
예제 #3
0
파일: NOXMAP.cpp 프로젝트: elitak/NoxTools
bool NOX_MAP::AddObject(char objName[], int X, int Y, int callback)
{
	/*RGBQUAD test;
	test.rgbBlue = 255;
	test.rgbRed = 255;
	Video.bmpfile.Set_Color(test);
*/
	int ObjNum =0;
	GNHT * obj;
	for(obj = Thing.Thing.Object.Objects.Get(); obj && strcmp(obj->Name,objName); obj = Thing.Thing.Object.Objects.Get(), ObjNum++);
	Thing.Thing.Object.Objects.ClearGet();

	OBJECT object;
    CSurface * surf = NULL;
    SURFACE tem;
    SURFACE * test = NULL;

	if( !obj )
      return(false);

	IDX_DB::Entry * Entry = NULL;
	IDX_DB::SectionHeader * Section = NULL;
    long val = 0;


		 // else if(obj->Stats.numNodes > 0 && obj->Stats.numNodes<2)
           //   val = *obj->Stats.Get(0)->Images.Get(0);

		  if(obj->Stats.numNodes)
              val = *obj->Stats.Get(0)->Images.Get(0);
		  else if(obj->PrettyImage!=NULL)
			  val = obj->PrettyImage;
		  else if(obj->MenuIcon!=NULL)
			  val = obj->MenuIcon;	
		  else
			  return(false);
	      if( val )
			  val++;
		  else
			  return(false);
          
		  if( !val || val < 0 )
			  return(false);

          //test = Objects.ObjImages.Find(val);
          if( val && !(test = Objects.ObjImages.Find(val)) )
		  {

		  Video.idx.GetAll((unsigned long)val,&Entry,&Section);


			  //Video.Extract(&file,Section,Entry,"c://TESTMAP.bmp");
			 // Display.Display->CreateSurfaceFromBitmap(&surf,"C://TESTMAP.bmp");
			 // if( surf )
			 //     surf->SetColorKey(RGB(0,0,0));
			  //remove("c://TESTMAP.bmp");
			  

///////////////////////////////////////////////////////////////////////////////////////////////
if( Entry )
{		  
	fstream file;
    file.open(Video.bagpath,ios::in | ios::binary);

	NxImage *img = Video.Extract(&file,Section,Entry);

	if( img && img->height >0 && img->width >0)
	{
		Display.Display->CreateSurface(&surf,img->width,img->height);
	if( surf )
		surf->SetColorKey(RGB(248,7,248));
		Display.BltBitmapData(img->data, img->width, img->height, surf->GetDDrawSurface());
	}	
		tem.surface = surf;
		tem.Height = img->height;
		tem.Width = img->width;
		tem.Image_ID = val;
		tem.ImgType = Entry->Entry_Type;
		tem.OffsetX = Entry->OffsetX;
		tem.OffsetY = Entry->OffsetY;
		//tem.img.Load(img->width,img->height,img->offsetX,img->offsetY,img->data,(char*)&img->ID);
		img->Unload();
		//LOAD THE NAME AS WELL NOW!!!!!
		Objects.ObjImages.Add(tem,val);
		test = &Objects.ObjImages.last->msg;

	file.close();
}	  
///////////////////////////////////////////////////////////////////////////////////////////////
		  }
		 object.imgID = val;
		 object.objID = ObjNum;
		 object.X = X;
		 object.Y = Y;
		 object.callbackID = callback;
		 if(test)
		 {
			object.Height = test->Height;
			object.Width = test->Width;
		 }
		 Objects.Objects.Add(object,object.callbackID);
	
	tem.surface = NULL;
	tem.name = NULL;
    surf = NULL;
	/*test.rgbBlue = 0;
	test.rgbRed = 0;
	Video.bmpfile.Set_Color(test);
*/
return(true);
}