Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > разработка игр, графический дизайн и моделирование > Gamedev - cоздание игр: Unity, OpenGL, DirectX
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 31.08.2011, 06:50   #1
VintProg
not
Участник клуба
 
Аватар для VintProg
 
Регистрация: 27.06.2009
Сообщений: 1,399
Вопрос HGE проблема с спрайтами...

Есть такой модуль:

Код:
#pragma once
#include "..\..\include\hge.h"
#include "..\..\include\hgefont.h"

//Игровой объект =====================================
//====================================================
class CObject
{

private:
	hgeSprite *fSpr;
	bool fDead;

public:
	float x;     //Позиция X
	float y;     //Позиция Y
	CObject(HTEXTURE texture);   //Конструктор
	~CObject();  //Деструктор
    void Update();
	void Draw();     
	void Kill();     //Убить объект
	bool IsDead();   //Проверка на смерть
};
Это cpp
Код:
#include "GameObjects.h"

//-------------- Внутриность ---------------------


//------------ Конуструктор ------------------
//============================================
CObject::CObject(HTEXTURE texture)
{
 fDead = false;
 x = 10.0; 
 y = 10.0;
 fSpr = new hgeSprite(texture, x, y, 334,200);
 //fSpr->SetBlendMode(BLEND_COLORADD | BLEND_ALPHABLEND | BLEND_NOZWRITE);

 //fSpr->SetTexture(texture);
}

//------------ Деструктор --------------------
//============================================
CObject::~CObject()
{
 fDead = true;
}

//------------ Процесс объекта ----------------
void CObject::Update()
{


}
//---------------------------------------------


//------------ Прорисовка ---------------------
void CObject::Draw()
{


//if (fSpr != NULL)
     fSpr->Render(x, y);

}

//------------ Жив ли объект? -----------------
bool CObject::IsDead()
{

if (fDead)
     return true;
     return false;
}


void CObject::Kill()
{
  fDead = true;
}
VintProg вне форума Ответить с цитированием
Старый 31.08.2011, 06:51   #2
VintProg
not
Участник клуба
 
Аватар для VintProg
 
Регистрация: 27.06.2009
Сообщений: 1,399
По умолчанию

И вот тут спрайт двигается фигово не как в омеге???

Код:
#include "..\..\include\hge.h"
#include "..\..\include\hgefont.h"
#include "GameObjects.h"


#define SCREEN_WIDTH  800
#define SCREEN_HEIGHT 600

#define MIN_OBJECTS	1
#define MAX_OBJECTS 8000


CObject *Object;

struct sprObject
{
	float x,y;
	float dx,dy;
	float scale,rot;
	float dscale,drot;
	DWORD color;
};




sprObject*	pObjects;
int			nObjects;
int			nBlend;

// Pointer to the HGE interface (helper classes require this to work)

HGE *hge=0;

// Resource handles

HTEXTURE			tex, bgtex;
hgeSprite			*spr, *bgspr, *spr2;
hgeFont				*fnt;

// Set up blending mode for the scene
bool FrameFunc()
{
	float dt=hge->Timer_GetDelta();
	float f= 0.0f;


	// Process keys
	if ( hge->Input_GetKey() == HGEK_UP )

         for (int i=0; i < 100; i++)
	        {
 		     f += 0.01;
		     Object->x += 0.1+f;
	        }


	switch(hge->Input_GetKey())
	{

		case HGEK_DOWN:		Object->x -= 1.7; break;
		case HGEK_ESCAPE:	return true;
	}

	return false;
}


bool RenderFunc()
{
	int i;
	
	// Render the scene
	
	hge->Gfx_BeginScene();
	bgspr->RenderEx(0,0, 0.0, 1.5, 1.5);
	//spr2->Render(100, 100);	
	Object->Draw();

	for(i=0;i<nObjects;i++)
	{
		spr->SetColor(pObjects[i].color); 
		spr->RenderEx(pObjects[i].x, pObjects[i].y, pObjects[i].rot, pObjects[i].scale);
	}
	fnt->SetScale(2.0);
	fnt->printf(7, 7, HGETEXT_LEFT, "UP and DOWN to adjust number of hares: %d\nSPACE to change blending mode: %d\nFPS: %d",
                     nObjects, nBlend, hge->Timer_GetFPS());

	
	hge->Gfx_EndScene();

	return false;
}

int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
	int i;

	hge = hgeCreate(HGE_VERSION);
	// Set desired system states and initialize HGE
	hge->System_SetState(HGE_LOGFILE, "hge_tut07.log");
	hge->System_SetState(HGE_FRAMEFUNC, FrameFunc);
	hge->System_SetState(HGE_RENDERFUNC, RenderFunc);
	hge->System_SetState(HGE_TITLE, "Test Game!!!");
	hge->System_SetState(HGE_USESOUND, false);
	hge->System_SetState(HGE_WINDOWED, true);
	hge->System_SetState(HGE_SCREENWIDTH, SCREEN_WIDTH);
	hge->System_SetState(HGE_SCREENHEIGHT, SCREEN_HEIGHT);
	hge->System_SetState(HGE_SCREENBPP, 32);
	//hge->System_SetState(HGE_FPS, 70);
	hge->System_SetState(HGE_SHOWSPLASH, false);
	

	if(hge->System_Initiate())
	{

		// Load textures

		bgtex = hge->Texture_Load("bg2.png");
		tex=hge->Texture_Load("PM_1.png");
		if(!bgtex || !tex)
		{
			// If one of the data files is not found,
			// display an error message and shutdown
			MessageBox(NULL, "Can't load BG2.PNG or ZAZAKA.PNG", "Error", MB_OK | MB_ICONERROR | MB_APPLMODAL);
			hge->System_Shutdown();
			hge->Release();
			return 0;
		}

		// Load font, create sprites

		fnt=new hgeFont("font2.fnt");
		spr=new hgeSprite(tex,0,0,334,200);
		spr2= new hgeSprite(tex,0,0,334,200);


		spr->SetHotSpot(32, 32);
		bgspr=new hgeSprite(bgtex,0,0,800,600);
		bgspr->SetBlendMode(BLEND_COLORADD | BLEND_ALPHABLEND | BLEND_NOZWRITE);
		bgspr->SetColor(0xFF0000FF,0);
		bgspr->SetColor(0xFFFF0000,1);
		bgspr->SetColor(0xFF000040,2);
		bgspr->SetColor(0xFF000040,3);

		// Initialize objects list

		pObjects=new sprObject[MAX_OBJECTS];
		nObjects=10;

		

		Object = new CObject(tex);




		


		// Let's rock now!

		hge->System_Start();

		// Delete created objects and free loaded resources

		delete[] pObjects;
		delete fnt;
		delete spr;
		delete bgspr;
		hge->Texture_Free(tex);
		hge->Texture_Free(bgtex);
	}

	// Clean up and shutdown

	hge->System_Shutdown();
	hge->Release();
	return 0;
}

Последний раз редактировалось Beermonza; 31.08.2011 в 16:40.
VintProg вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц

Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск


Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Работа с анимированными спрайтами в XNA GS 4.0 Renat21 Помощь студентам 0 06.07.2011 23:53
составление Библиотеки процедур для работы со спрайтами TransSpr в turbo pascale 7.0 сергей12345 Помощь студентам 0 27.03.2011 15:49
HGE к дельфи... VintProg Gamedev - cоздание игр: Unity, OpenGL, DirectX 5 18.12.2010 18:07
hge и C++ Olejik Общие вопросы C/C++ 2 09.07.2010 19:50
Проблема с рамами/Проблема с ЖД DRAGGER Компьютерное железо 6 04.01.2009 23:37