All Discussions - HGE http://relishgames.com/forum/index.php?p=/discussions/feed.rss Thu, 23 May 13 13:27:35 -0400 All Discussions - HGE en-CA sizeof(structure) in win64 http://relishgames.com/forum/index.php?p=/discussion/6431/sizeofstructure-in-win64 Tue, 21 May 2013 09:25:55 -0400 SantalLican 6431@/forum/index.php?p=/discussions

typedef struct tagRECT
{
LONG left;
LONG top;
LONG right;
LONG bottom;
} RECT, *PRECT, NEAR *NPRECT, FAR *LPRECT;



t_struct = add_structure_item();
(*t_struct) = HIClass(NAME(f_RECT), sizeof(RECT));
t_struct->add_item(0)->set(NAME(f_left), h_Int);
t_struct->add_item(4)->set(NAME(f_top), h_Int);
t_struct->add_item(8)->set(NAME(f_right), h_Int);
t_struct->add_item(12)->set(NAME(f_bottom), h_Int);


Where 0, 4, 8, and 12 are the positions of RECT's variables. But I worry about sizes of variables in Win32 and Win64. For example normally sizeof(RECT) is 16 but in Win64 it may be up to 32. Is it true? Are these codes compatible with both Win32 & Win64?]]>
typedef vs macro http://relishgames.com/forum/index.php?p=/discussion/6430/typedef-vs-macro Thu, 16 May 2013 05:46:12 -0400 SantalLican 6430@/forum/index.php?p=/discussions

typedef unsigned int uint32;
#define DWORD unsigned int

uint32 myint1;
DWORD myint2;

]]>
my own vector http://relishgames.com/forum/index.php?p=/discussion/6428/my-own-vector Sat, 11 May 2013 20:42:25 -0400 SantalLican 6428@/forum/index.php?p=/discussions
- begin() : return _array_start;
- end() : return _current;

- (_array_end - _array_start) == capacity
- (_current - _array_start) == current_size
- (_current == _array_end) -> vector is full

- Push back : *_current++ = val;
- Pop back : _current--;


And here is my vector (I haven't tested all functions & features yet) :



#define __DESTRUCTOR(ty, ptr) (ptr)->~ty()
#define __CONSTRUCTOR(ty, ptr) (*ptr) = ty()
#define _vector_start _vector_data
#define _vector_capacity (_vector_end - _vector_start)
#define _vector_size (_current - _vector_start)

template
class tVector
{

public:

inline tVector() : _vector_data((T*) new char[sizeof(T) * 1]),
_current(_vector_start), _vector_end(_vector_data + 1){}

inline tVector(int nElements) : _vector_data(new char[sizeof(T) * nElements]),
_current(&_vector_data[nElements]), _vector_end(_current){}

inline tVector(int nElements, const T& val) : _vector_data((T*) new char[sizeof(T) * nElements]), _vector_end(_vector_data + nElements){
for(_current = _vector_data;_current != _vector_end;){*_current++ = val;}
}

inline tVector(tVector &object){
if((_vector_capacity) < object.size()) allocate(object.size());
memcpy(_vector_data, object._vector_data, object.size() * sizeof(T));
_current = _vector_start + object.size();
}

inline operator= (tVector &object){
if((_vector_capacity) < object.size()) allocate(object.size());
memcpy(_vector_data, object._vector_data, object.size() * sizeof(T));
_current = _vector_start + object.size();
}

inline ~tVector(){delete [](char*)_vector_data;}

inline void push_back(const T &t){
if(_current == _vector_end)double_size();*_current++ = t;
}

inline T& push_back_and_access(const T &t){
if(_current == _vector_end)double_size();*_current++ = t;return _current[-1];
}

inline void pop_back(){_current -= (_current != _vector_start);}
inline void pop_back_and_destroy(){
if(_current != _vector_start){_current--;__DESTRUCTOR(T, _current]);}}

inline void resize(size_t size){
if((_vector_size) == size)return;

T *it;
if((_vector_size) < size){
if((_vector_capacity) < size)
{
T *_temp = (T*) new char[sizeof(T) * size];
_current = _temp + (_vector_size);
memcpy(_temp, _vector_data, (unsigned int)((char*)_vector_end - (char*)_vector_start));
_vector_end = (_temp + size);
delete [] (char*)_vector_data;_vector_data = _temp;return;
}else
{
it = _current;
_current = (_vector_start + size);
for(;it < _current;it++)__CONSTRUCTOR(T, it);
}}
else
{
it = _current;
_current = (_vector_start + size);

if(it != _current)
do{it--;__DESTRUCTOR(T, it);}while(it != _current);

}
}

inline void resize(size_t size, const T& val){
if((_vector_size) == size)return;

T *it;
if((_vector_size) < size){
if((_vector_capacity) < size)
{
T *_temp = (T*) new char[sizeof(T) * size];
_current = _temp + (_vector_size);
memcpy(_temp, _vector_data, (unsigned int)((char*)_vector_end - (char*)_vector_start));
_vector_end = (_temp + size);
delete [] (char*)_vector_data;_vector_data = _temp;return;
}else
{
it = _current;
_current = (_vector_start + size);
for(;it < _current;)*it++ = val;
}}
else
{
it = _current;
_current = (_vector_start + size);

if(it != _current)
do{it--;__DESTRUCTOR(T, it);}while(it != _current);

}
}

inline T* insert(T * pos, const T &val){
if(pos >= _current)return 0;
unsigned int _pos = (pos - _vector_start);
if(_current == _vector_end)
{double_size();pos = _vector_start + _pos;}

for(T *it = _current++;it != pos;)*it-- = it[-1];
*pos = val;return pos;
}

inline void insert(T * pos, size_t n, const T &val){
if(pos >= _current)return;
unsigned int _pos = (pos - _vector_start);

_current += n;
if(_current >= _vector_end)
{double_size();pos = _vector_start + _pos;}

T *end = pos + n;
for(T *it = _current - n - 1;it >= pos;)
it[n] = *it--;

for(;pos != end;)*pos++ = val;
}

inline void insert(T * pos, T* first, T *last){
if(pos >= _current || first >= last)return;
unsigned int _pos = (pos - _vector_start);

_current += (last - first);
if(_current >= _vector_end)
{double_size();pos = _vector_start + _pos;}

int n = (last - first);
T *end = pos + n;
for(T *it = _current - n - 1;it >= pos;)
it[n] = *it--;
for(;pos != end;)*pos++ = *first++;
}

inline void assign(size_t size, const T &val){if(!size)return;
if(_current != _vector_start)
for(T *it = _vector_data;it < _current;it++)__DESTRUCTOR(T, it);
if((_vector_capacity) < size)allocate(size);
_current = _vector_start + size;

for(T *it = _vector_start;it < _current;){*it++ = val;}
}

inline void shrink_to_fit(){
if(_current == _vector_end || _current == _vector_start)return;

T *_temp = (T*) new char[sizeof(T) * (_vector_size)];
memcpy(_temp, _vector_data, (unsigned int)((char*)_current - (char*)_vector_start));
_current = _temp + (_vector_size);
delete [] (char*)_vector_data;_vector_data = _temp;_vector_end = _current;
}

inline void reverse(int count = 0){
size_t half_size = ((unsigned int)(_vector_size)) / 2;
if(count && count < half_size)half_size = count;
char temp[sizeof(T)]; //avoid constructors
T*_end = _vector_end - 1;

for(int i = 0;i < half_size;i++)
{
*((T*)temp) = (_vector_start)[i];
(_vector_start)[i] = (_end)[-i];
(_end)[-i] = *((T*)temp);
}
}

inline void erase(unsigned int pos){
if(_current == _vector_start || pos >= (_vector_size))return;
__DESTRUCTOR(T, &_vector_data[pos]);

for(T *it = &_vector_data[pos + 1];it < _current;){it[-1] = *it++;}
_current--;
}

inline void erase(T *pos){
if(pos >= _current)return;
__DESTRUCTOR(T, pos);

T *__current = _current--;
for(pos++;pos < __current;){pos[-1] = *pos++;}
}

inline void erase(T *first, T *last){
if(last >= _current)return;

for(T *it = first;it < last;it++)
{__DESTRUCTOR(T, it);}

T *__current = _current;
_current -= (last - first);
for(;it < __current;){*first++ = *it++;}

}

inline void erase(unsigned int first, unsigned int last){
unsigned int range = last - first;
if(first >= last || (_current - range < _vector_start) || last >= (_vector_size))return;

T *end = &_vector_data[last];
for(T *it = &_vector_data[first];it < end;it++)
{__DESTRUCTOR(T, it);}
range = -range;

for(;it < _current;){it[range] = *it++;}
_current += range; //it's negative
}


inline void swap(tVector &obj){
T *__current = _current;
T *__vector_start = _vector_start;
T *__vector_end = _vector_end;
_current = obj._current;
_vector_start = obj._vector_start;
_vector_end = obj._vector_end;
obj._current = __current;
obj._vector_start = __vector_start;
obj._vector_end = __vector_end;
}

inline void clear(bool bDestroy = false){
if(bDestroy)for(T *it = _vector_data;it < _current;it++){__DESTRUCTOR(T, it);}
_vector_end = _vector_start;_current = _vector_data;}

inline void reset(){_current = _vector_start;}
inline void reserve(size_t max){if(max > (_vector_capacity))new_size(max);}
inline size_t size() const {return _vector_size;}
//inline void set_size(size_t new_size){if(new_size < vector_capacity)_current = _vector_start + new_size;}
inline T& at(unsigned int index) const {return _vector_start[index];}
inline bool empty(){return ((_vector_capacity) <= 0);}<br /> inline T* data() const {return _vector_start;}
inline T* begin() const {return _vector_start;}
inline T* end() const {return _current;}
inline T& front() const {return *_vector_start;}
inline T& back() const {return _current[-1];}
inline size_t capacity() const {return (_vector_capacity);}
T& operator[] (unsigned int index) const {return _vector_start[index];}
inline size_t max_size() const {allocator obj;return obj.max_size();}

_PROTECTED :
T *_vector_data, *_current, *_vector_end;

private :

inline void allocate(size_t size){
delete [] _vector_data;
_vector_data = (T*) new char[sizeof(T) * size];
_current = _vector_start;
_vector_end = (_vector_start + size);
}


inline void double_size(){
T *_temp = (T*) new char[sizeof(T) * (unsigned int)(_vector_capacity) * 2];
_current = _temp + (_vector_capacity);
memcpy(_temp, _vector_data, (unsigned int)((char*)_vector_end - (char*)_vector_data));
_vector_end = _temp + (_vector_capacity) * 2;
delete [] (char*)_vector_data;_vector_data = _temp;
}

inline void new_size(size_t size)
{
T *_temp = (T*) new char[sizeof(T) * size];
_current = _temp + (_vector_size);
memcpy(_temp, _vector_data, (unsigned int)((char*)_vector_end - (char*)_vector_data));
_vector_end = _temp + size;
delete [] (char*)_vector_data;_vector_data = _temp;
}
};
#undef __DESTRUCTOR
#undef __CONSTRUCTOR
#undef _array_start
#undef _vector_capacity
#undef _vector_size


EDIT : Here is my simple test about (vector vs tVector)
http://pastebin.com/DxCRBG0n
(I tested it in release mode)

Any suggestions?]]>
Выбор игрока http://relishgames.com/forum/index.php?p=/discussion/6429/vybor-igroka Sun, 12 May 2013 03:40:19 -0400 alex 6429@/forum/index.php?p=/discussions Функция framefunc крутится постоянно и из-за этого я не могу сделать так:
1.выбор игрока, который отвечает
2.input()
3.сравнение
Выходит только сперва ввод, а потом нажатие.


bool FrameFunc()
{
chr=hge->Input_GetChar();
c=a+b;
if (hge->Input_GetKeyState(HGEK_F1))
{

char res[10](" ");
_itoa_s(c,res,10);
if (equ(s,res))
{
points1+=1;
hge->Effect_PlayEx(snd,100,0,1,0);
a=hge->Random_Int(1,9);
b=hge->Random_Int(1,9);

}
else
{
points2+=1;
a=hge->Random_Int(1,9);
b=hge->Random_Int(1,9);
}
clear(s);
Sleep(800);

}
if (hge->Input_GetKeyState(HGEK_F2))
{

char res[10](" ");
_itoa_s(c,res,10);
if (equ(s,res))
{
points2+=1;
hge->Effect_PlayEx(snd,100,0,1,0);
a=hge->Random_Int(1,9);
b=hge->Random_Int(1,9);

}
else
{
points1+=1;
a=hge->Random_Int(1,9);
b=hge->Random_Int(1,9);
}
clear(s);
Sleep(800);

}
input();

get();

if (hge->Input_GetKeyState(HGEK_ESCAPE)) return true;
return false;
}
]]>
Mercior's Animator http://relishgames.com/forum/index.php?p=/discussion/4407/merciors-animator Mon, 22 Dec 2008 10:03:44 -0500 mercior 4407@/forum/index.php?p=/discussions
Using this method of animation can save a lot of memory over traditional 1-sprite-per-frame type animation, especially when you want to animate a large object.

I am releasing the editor in this post, and included in the download link is source code (a single .h file) with a class to play back the files that the animation editor saves.

I don't have any documentation written for the editor but the buttons are pretty self explanitory and I've detailed keyboard shortcuts below, so let me know what you think!

Latest Version:
http://www.mercior.com/files/AnimatorSDK.zip

http://uk.youtube.com/watch?v=1QUjh3BQjGY (a little outdated)

Some keyboard shortcuts:
[list]
+ Ctrl+Z = Undo
+ Spacebar = Play / Stop
+ Q, E = Next / Last Frame
+ Shift+Click = Add to selection
+ PGUP/PGDN = Increase/Decrease soft selection radius
+ WASD = Move nodes
+ Shift+W/S = Scale Nodes
+ Shift+A/D = Rotate Nodes
[/list:u]


image]]>
Wrongly sized window http://relishgames.com/forum/index.php?p=/discussion/6427/wrongly-sized-window Sun, 05 May 2013 20:38:15 -0400 DeathRay2K 6427@/forum/index.php?p=/discussions image
That's with a windows specified as 640x360. In reality it ends up being 630x350. But in every way it continues to act as though it's 640x360 (Coordinates inside the window work out that way), except when it's output to the screen. Ignoring the text in the top left, you can see the bands where rows and columns of pixels are simply skipped to arrive at the 630x350 final resolution. This doesn't happen in fullscreen, only while windowed.

I'm in Windows 8, compiling with VS2012.
Any ideas?]]>
HGE и широкоформатный монитор http://relishgames.com/forum/index.php?p=/discussion/4901/hge-i-shirokoformatnyy-monitor Wed, 03 Jun 2009 13:32:50 -0400 stayer 4901@/forum/index.php?p=/discussions Конкурс на создание 2d космической стрелялки с призами http://relishgames.com/forum/index.php?p=/discussion/6426/konkurs-na-sozdanie-2d-kosmicheskoy-strelyalki-s-prizami Fri, 03 May 2013 13:58:38 -0400 bandiMonty 6426@/forum/index.php?p=/discussions Молодой ресурс для разработчиков игр GamesMaker.ru объявляет конкурс на создание 2d космической стрелялки.

Призовой фонд
1 место - 2500 руб
2 место - 1500 руб
3 место - 1000 руб
4 место - ???
5 место - ???

Желающим принять участие в дополнительном спонсорстве пишите в лс.

Примеры
Создание космической стрелялки в HGE
В данном уроке рассмотрен полный цикл создания подобной игры на 2d c++ движке hge
p.s. сделать такое можно за 1 вечер!)))

Правила
1. В конкурсе могут участвовать игры, которые не были ранее где либо опубликованы. Участники конкурса не должны публиковать свои проекты до окончания конкурса.

2. Для создания игры могут использоваться любые языки программирования, конструкторы, инструменты, клипарты, библиотеки.

3. Игра должна запускаться и работать на любом современном компьютере с Windows XP. Все необходимые библиотеки и драйверы должны входить в состав дистрибутива игры, который не должен превышать 50 Мб.

4. Игра должна содержать по крайней мере один полноценный уровень с боссом в конце, 3 вида оружия, 3 вида врагов.

5. Игра может создаваться командой из любого количества участников

6. При загрузке игры вывести наш логотип, для подтверждения, что сделали сами (Можно его менять под стилистику игры)
http://gamesmaker.ru/img/site/logo.png

7. Жанр игры - TDS, аркада

Прием работ
Ссылки на работы присылайте через форму обратной связи http://gamesmaker.ru/contacts/ до 15 июня 2013 года.

Укажите так же использованный язык программирования, движок и прочие вспомогательные вещи.
При получении от вас игры, будет остослано обратное письмо, подтверждающее прием вашей игры.

Работы, принятые на участие в конкурсе, а так же победители будут опубликованы по окончании конкурса на сайте GamesMaker.ru

Обсуждение на форуме http://gamesmaker.ru/forum/topic/117/

Помните, пожалуйста, конкурс проводится исключительно в целях стимуляции вас и вашего творческого развития, а так же в рамках развития молодого ресурса GamesMaker.ru]]>
Copy target to new texture? http://relishgames.com/forum/index.php?p=/discussion/6425/copy-target-to-new-textures Mon, 29 Apr 2013 21:35:35 -0400 Rectangle 6425@/forum/index.php?p=/discussions Since HGE creates it's textures using D3DPOOL_MANAGED, I appear to be limited on how to achieve this.
Using the same IDirect3DDevice9 pointer which HGE uses, I have attempted to get this to work using GetRenderTargetData, UpdateSurface, UpdateTexture, etc... and all attempts have failed with either E_FAIL or D3DERR_INVALIDCALL.

So I have the following questions:

  • What was the reasoning behind using D3DPOOL_MANAGED for texture creation?
  • Is it safe to modify HGE to use D3DPOOL_SYSTEMMEM instead? Would there be any negative downsides?
  • Other than using a slow, manual texture lock/copy/unlock operation, how could I copy HTARGET data to a newly created D3DPOOL_MANAGED texture?
]]>
grids http://relishgames.com/forum/index.php?p=/discussion/6424/grids Mon, 29 Apr 2013 10:09:20 -0400 khizer 6424@/forum/index.php?p=/discussions I have a questions regarding making grids in HGE , do we have a default statement that creates a window with grid or should i load a texture image with grids on it .
i hope you understand the question

regards]]>
Programmatic tile transitioning? http://relishgames.com/forum/index.php?p=/discussion/6423/programmatic-tile-transitionings Tue, 23 Apr 2013 02:37:33 -0400 Rectangle 6423@/forum/index.php?p=/discussions Instead of honing my incredibly bad artistic drawing skills, and making several tiles which transition between grass and dirt in all directions, is there a way I could simply blend these two tiles together?

For example, please note the following image:
image
The areas in the image where black becomes white should be the point in the new tile where the image "crosses over" from one tile image to the next, in a gradient-like fashion, based entirely on adjacent tiles.
I could make several grayscale gradient images to represent these transitions, and somehow use those to "bleed" between tile images.
Once all tiles are loaded into the game, I would create these transitions and add them to the array of tiles used by the map.

I know this would require some sort of alpha-blending trick, but how could this be done in HGE?
AFAIK, I would need to create texture objects for each generated tile, but does anyone know what the correct steps would be in order to properly render these tiles?

EDIT: I believe something LIKE THIS is what I'm going for

(but how can it be done in HGE?)]]>
Snake project http://relishgames.com/forum/index.php?p=/discussion/6422/snake-project Mon, 22 Apr 2013 08:50:40 -0400 khizer 6422@/forum/index.php?p=/discussions I'm doing snake project with HGE and C++,
I'm have a problem with snakes self collision ,it doesn't work at all maybe im totally wrong at my thinking.
the idea behind is:

Snake* play = NULL; //this will load snake's sprite .

if( play->GetBoundingBox().Intersect(&play->GetBoundingBox()))
{
///here i will use logic to terminate the snake///
}
The issue is when i intersect snake with a different Sprite e.g Food it works fine ,
but not with its own...i get weird results i.e it collides with itself every second as it moves.

Any advise on this ?

regards
]]>
2D Tile engine rendering optimizations http://relishgames.com/forum/index.php?p=/discussion/6421/2d-tile-engine-rendering-optimizations Tue, 16 Apr 2013 20:33:04 -0400 Rectangle 6421@/forum/index.php?p=/discussions This tile layer can easily render without any drop in FPS.
Now lets scale that up to 100 columns and 100 rows.
This will obviously create a HUGE drop in the application's frame rate, since the render operation is doing 10 times the work.

So, in a scenario such as this, what kind of optimizations could be made to ensure a constant frame rate?
I suppose the first obvious thing to do would be to switch my engine's logic to using batch operations.
But another thing I thought of was somehow determining if a given tile was within the limits of the screen, and only drawing it if it is.
But how could something like that be achieved? And would it be possible to combine these ideas?
Also, any other advice on optimizations are welcomed. I'm curious to hear what anyone has in mind!]]>
Does HGE support PNG tranparency/opacity? http://relishgames.com/forum/index.php?p=/discussion/6420/does-hge-support-png-tranparencyopacitys Tue, 16 Apr 2013 18:44:26 -0400 Rectangle 6420@/forum/index.php?p=/discussions I also know that HGE uses libPNG to handle the png file format...

But how does HGE handle any transparent/semi-transparent regions embedded within a PNG image?
Are they dealt with automatically during Texture_Load and GFX_* rendering operations?
Is there a certain rendering algorithm to follow in order to get it to display properly?
Or perhaps only specific PNG file format(s) are supported?

I'm asking because I used photoshop to create a tile outline (just a simple red border with a transparent background, and a semi-transparent 'glow' surrounding the inner edges of the border) and I couldn't get it to show up in my tile engine application.
I stepped through my code, and can verify that the texture does in fact load properly.
And if I replace the Texture_Load operation to use 'texture.jpg' from Tutorial 05, it also renders properly.]]>
Как посмотреть принцип работы hgeGUI? http://relishgames.com/forum/index.php?p=/discussion/6419/kak-posmotret-princip-raboty-hgeguis Mon, 15 Apr 2013 07:28:03 -0400 OdIUm 6419@/forum/index.php?p=/discussions а как мне увидеть непосредственно саму обработку...cpp?
я подозреваю все это хранится в lib...но visual c++ не открывает его...с помощью блокнота - тоже фигня получается...
как бы мне посмотреть?

Хочу просто написать свой класс на основе hgegui ..]]>
Code help [building own interpreter] http://relishgames.com/forum/index.php?p=/discussion/6400/code-help-building-own-interpreter Sat, 12 Jan 2013 03:49:57 -0500 SantalLican 6400@/forum/index.php?p=/discussions I got a very big idea that's how to run and enjoy a program directly and instantly without using modern compilers to compile and link your code.

About programming languages : Modern compilers have to compile, check, link and build up an executable file with the code that users specified. The executable files are presented in a way that everyone called "Assembly". But that's unique. My idea is building up a portable interpreter that may be a great plugin for HGE. It also knows C++ standard syntax, reads, compiles, generates, and runs code at a time. Also it's portable, so also you can freely switch to an another program at any time you want. In short now each source file is really a program that you can instantly enjoy it... :)

About my idea : I thought up some important steps : I'll develop almost of standard C++ syntax, build up variable-structure definition, variable array, variable construction, variable attributes, container variable, operators, layered expressions, bracket [] expression, perform variable operations, function definition, function returning value, call a function with parameters, add all standard functions, add my own core functions, then finally, HGE... :)
- About variable definition : int; short; long; char; bool; float; double
- About array : one dimensional, multiple dimensional
- About variable attributes : const, signed, unsigned
- About operators : (+); (-); (*); (/); (%); (^); (>); (<); (>=); (<=); (==); (!=); (!); (>>); (<<); (&); (|) (&&); (||); (,);</b>


Also I think maybe C++ does not support power operator (^); so I'll try to include it. Is this possible?

Before implementing, I'd like to hear some advice, opinions or suggestions. :)
- What do you think about this idea?
- What is requirement? Am I able to implement this great idea? Is this possible?
- About my draft : what is missing, what is wrong, or any suggestion? Thank you. :)]]>
Пытаюсь набросать игруху http://relishgames.com/forum/index.php?p=/discussion/6418/pytayus-nabrosat-igruhu Tue, 09 Apr 2013 10:47:59 -0400 Allxumuk 6418@/forum/index.php?p=/discussions

//------------------------------------------------------------
// Cosmos Game xD v0.0001f
//------------------------------------------------------------
#pragma comment (lib, "hge.lib")
#pragma comment (lib, "hgehelp.lib")

//Include-----------------------------------------------------
#include
#include
#include
#include
#include

//Globals-----------------------------------------------------
HGE* hge = NULL;

const float SCR_WIDTH = 800.0f;
const float SCR_HEIGHT = 600.0f;

bool fire = false;

hgeSprite* g_sPlayer = NULL;
hgeVector g_vPlayer = hgeVector(SCR_WIDTH/2, SCR_HEIGHT-30);

hgeAnimation* g_aFire = NULL;
hgeVector g_vFire = hgeVector(0, 0);

hgeSprite* g_sBullet = NULL;
hgeVector g_vBullet = hgeVector(0, 0);
hgeVector g_vSpeedB = hgeVector(0, -1.0);

HTEXTURE g_tPlayer = NULL;
HTEXTURE g_tFire = NULL;
HTEXTURE g_tBullet = NULL;

//Frame-------------------------------------------------------
bool Frame()
{
float dt = hge->Timer_GetDelta(); // no comments
float lol; // no problem :)

// Set player coordinate
hge->Input_GetMousePos(&g_vPlayer.x, &lol);

// Vector of fire
g_vFire = hgeVector(g_vPlayer.x, SCR_HEIGHT-71);

// Vector of bullet
g_vBullet = hgeVector(g_vFire.x, g_vFire.y-19);

// Fire
if(hge->Input_GetKeyState(HGEK_LBUTTON))
{
fire = true;
g_aFire->Resume();

g_vBullet += g_vSpeedB;
}
else
{
fire = false;
g_aFire->Stop();
}

// Update fire animation
g_aFire->Update(dt);

// Exit
if(hge->Input_GetKeyState(HGEK_ESCAPE)) return true;

return false;
}
//Render------------------------------------------------------
bool Render()
{
hge->Gfx_BeginScene();
hge->Gfx_Clear(0x0);

// Render player
g_sPlayer->Render(g_vPlayer.x, g_vPlayer.y);

// Render fire
if(fire)
{
g_aFire->Render(g_vFire.x, g_vFire.y);
}

g_sBullet->Render(g_vBullet.x, g_vBullet.y);

hge->Gfx_EndScene();

return false;
}

//WinMain-----------------------------------------------------
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
hge = hgeCreate(HGE_VERSION);

hge->System_SetState(HGE_USESOUND, false);
//hge->System_SetState(HGE_HIDEMOUSE, false);
hge->System_SetState(HGE_WINDOWED, true);
hge->System_SetState(HGE_LOGFILE, "file.log");
hge->System_SetState(HGE_FRAMEFUNC, Frame);
hge->System_SetState(HGE_RENDERFUNC, Render);
hge->System_SetState(HGE_FPS, HGEFPS_VSYNC);

if(hge->System_Initiate())
{
// Player
g_tPlayer = hge->Texture_Load("..\\player.png");
g_sPlayer = new hgeSprite(g_tPlayer, 0, 0, 52.0, 36.0);
g_sPlayer->SetHotSpot(26.0, 18.0);

// Fire
g_tFire = hge->Texture_Load("..\\plsm.png");
g_aFire = new hgeAnimation(g_tFire, 6, 21, 0, 0, 13.0, 39.0);
g_aFire->SetHotSpot(6.5, 19.5);

// Bullet
g_tBullet = hge->Texture_Load("..\\bullet.png");
g_sBullet = new hgeSprite(g_tBullet, 0, 0, 3.0, 11.0);
g_sBullet->SetHotSpot(1.5, 5.5);

hge->System_Start();

// Free resource
hge->Texture_Free(g_tPlayer);
hge->Texture_Free(g_tFire);
hge->Texture_Free(g_tBullet);
delete g_sPlayer;
delete g_aFire;
delete g_sBullet;
}

hge->System_Shutdown();
hge->Release();

return 0;
}
]]>
HGE now officially incompatible with MingW http://relishgames.com/forum/index.php?p=/discussion/6417/hge-now-officially-incompatible-with-mingw Mon, 01 Apr 2013 23:46:58 -0400 formerBGIuser 6417@/forum/index.php?p=/discussions no longer runs properly with the version of MingW that
comes with the latest version of the CodeBlocks IDE (12.11).]]>
Одна картинка или несколько маленьких? http://relishgames.com/forum/index.php?p=/discussion/6416/-odna-kartinka-ili-neskolko-malenkihs Mon, 01 Apr 2013 07:54:21 -0400 OdIUm 6416@/forum/index.php?p=/discussions Надо сделать двигающуюся камеру по 4м направлением на величину экрана. То есть надо 5 точек, где останавливается камера.
Есть ли разница в производительности между 1 большой загружаемой в спрайт png картинкой разрешением 3027 на 2304 или
5 картинками 1024 на 768 и компановки их с помощью кода?
Что будет работать быстрее и меньше грузить систему?
HGE автоматически отсекает у спрайта не видимые части?]]>
error LNK2026: module unsafe for SAFESEH image. (hgehelp.lib) http://relishgames.com/forum/index.php?p=/discussion/6415/error-lnk2026-module-unsafe-for-safeseh-image.-hgehelp.lib Sat, 23 Mar 2013 16:14:49 -0400 DeathRay2K 6415@/forum/index.php?p=/discussions Thanks,
Garnet]]>
7 и 1 вопрос по продвинутому меню на HGE) http://relishgames.com/forum/index.php?p=/discussion/6413/7-i-1-vopros-po-prodvinutomu-menyu-na-hge Fri, 15 Mar 2013 06:10:44 -0400 OdIUm 6413@/forum/index.php?p=/discussions
http://www.youtube.com/watch?feature=player_embedded&v=Hl7Zvij-VQ0

То есть меня интересует:

1) С точки зрения кода - лучше это делать в одном классе Menu и там прописывать все части? Или каждый элемент (фон, левое меню, правое меню) - это отдельный класс и прописывается отдельно, а потом все соединяется? Понятно что можно сделать по разному, но как удобнее, исходя из вашего опыта?

2) Анимированый фон. Это одна большая картинка, которая двигается медленно? Или это несколько разных спрайтов?

3) Кнопки слева - это уже готовые картинки с текстом в двух видах (обычный текст и подсвеченный) и при клике они меняются на мгновение? Или нарисована только кнопка, а текст выводится сверху через gui->AddCtrl? Или каким лучше способом это делать? Если заранее как картинка, то получается под каждое разрешение надо создавать свою кнопку? Или как?

4) Самый главный вопрос, выдвигающаяся часть меню. Как это сделать? То есть я близко не представляю...Если делать это как картинку, которая сначала двигается, а когда заканчивает - заменяется уже интерактивным меню - но мне кажется, это не правильно... А если двигать все элементы (кнопки и проч), то это надо какой-то обработчик писать, который бы все рассчитывал... в общем буду рад любым советом по реализации такого...

5) В кредитсах плывет текст, который идет снизу вверх и плавно появляется...Как такое реализовать?

6) В опциях есть слайдеры, которые меняют громкость музыки и звуков. Через что их делать в HGE? есть инструмент?

7) При нажатии "Новая игра" появляется окошко для ввода имени...каким образом это реализовано?


Понимаю что вопросов много и может быть глупые, но буду рад за подсказки и советы... А если кто-то выложит исходники или примеры реализации подобных вещей - буду благодарен.


И еще вопрос не по теме:

Каким образом рассчитывать координаты расположения объектов на экране? Ну текста, кнопок и т.п.? Ну чтоб они располагались на нужных местах? Ну просто сейчас я пишу так:
gui->AddCtrl(new cGUI(MS_PLAY,    fntMenu, onsnd, pshsnd, hge->System_GetState(HGE_SCREENWIDTH)/2.0f - fntMenu->GetStringWidth("НОВАЯ ИГРА")/2.0f, hge->System_GetState(HGE_SCREENHEIGHT)/2.0f-60, "НОВАЯ ИГРА"));

То есть по сути расположение надписи я вручную подбираю...смотря где располагается.. Может есть какой-то более удобный вариант, до которого я не дошел?
Потому что этот вариант не очень удобен(


Буду благодарен за любые советы, примеры и подсказки)
]]>
Помогите разобраться с кодом http://relishgames.com/forum/index.php?p=/discussion/6414/pomogite-razobratsya-s-kodom Sun, 17 Mar 2013 03:35:54 -0400 pashqacpp 6414@/forum/index.php?p=/discussions Опыта программирования у меня можно считать нету, много изучаю книг по языку(уже давно), но с практикой проблема... её нет. Сегодня проснувшись решил попробовать идти в сторону ртс - создать спрайт и выделять его, двигать. Вобщем куски нужные в ртс написать. Сразу скажу с математикой не очень дружу - векторы, матрицы итд, читал конечно в книгах о программировании игр, но использовать не могу :(
Так вот - кусок кода и вопрос: Почему cout не срабатывает?

if(hge->Input_GetKeyState(HGEK_LBUTTON))
{
float ix, iy, iw, ih;
float x1, x2, y1, y2;
float mx, my;
bool getobj = false;

one->GetTextureRect(&ix,&iy,&iw,&ih);
hge->Input_GetMousePos(&mx,&my);

x1 = ix; y1 = iy; x2 = ix+iw; y2 = iy+ih;

if(x2>mx && x1 {
cout << "if x\n";<br /> if(y2>my && y1 {
getobj = true;

cout << "getobj = true!\n";<br /> }
cout << "getobj Y fail\n";<br /> }
}

]]>
Моя первая проба HGE(прототип игры http://relishgames.com/forum/index.php?p=/discussion/6097/moya-pervaya-proba-hgeprototip-igry Fri, 06 May 2011 17:38:21 -0400 goil13 6097@/forum/index.php?p=/discussions



Ещё недавно попробовали ТД сделать накидали шаблончик за пару дней:
http://s51.radikal.ru/i132/1105/aa/4ea2566f691c.jpg]]>
Обращение к отдельным пикселям текстуры http://relishgames.com/forum/index.php?p=/discussion/6276/obraschenie-k-otdelnym-pikselyam-tekstury Sat, 05 Nov 2011 12:30:04 -0400 Legend 6276@/forum/index.php?p=/discussions Using Resource Packs http://relishgames.com/forum/index.php?p=/discussion/6412/using-resource-packs Sun, 10 Mar 2013 10:28:18 -0400 blackdynamite 6412@/forum/index.php?p=/discussions
after you compile a resource pack e.g data.paq, how do you go about using whatever is in the resource pack? for example, let's say you have saved a .png image for a texture in the pack file, how do you load the pack file and access the image to load it in the texture? am sure the resource functions only work with a resource script so i was wondering how you go about using these.]]>
использование больших текстур в анимации http://relishgames.com/forum/index.php?p=/discussion/6411/ispolzovanie-bolshih-tekstur-v-animacii Fri, 08 Mar 2013 20:29:08 -0500 bznv_v 6411@/forum/index.php?p=/discussions
начав разбираться с hgeAnimation, увидел, что вся анимация загоняется в один png файл, что мне кажется отнюдь не самым рациональным решением, чем нежели например просто массив quad-ов или спрайтов, но тут я скорее всего не прав, и был бы рад услышать чьи либо мнения на этот счет.

проблема такая: есть 20 кадров в среднем разрешение 2000*2000, анимационная лента получается 20000* 2000 пикселей. при этом первые 6 кадров визуализируются правильно, после чего изображение начинает исчезать и появляться в левых и правых концах кадра, как будто я неправильно разметил изображение. но из-за исправности первых 6 кадров, я подозреваю, что проблема с большим разрешением текстуры.

какие можно найти другие решения в данном вопросе? как можно реализовать анимацию текстур с высоким разрешением?
думал попробовать просто поочередно подгружать 3 разные текстуры в анимацию, но потом понял, что не смогу узнать, когда нужно заканчивать одну и начинать другую.]]>
Выделение памяти и stl list http://relishgames.com/forum/index.php?p=/discussion/6410/vydelenie-pamyati-i-stl-list Wed, 27 Feb 2013 13:29:35 -0500 Legend 6410@/forum/index.php?p=/discussions
1) При обычном создании объекта все работает, а при добавлении объектов в list, в деструкторе hge->Texture_Free(texture); вызывает ошибку. Почему так?


class Object
{
public:
int x,y;
hgeSprite *spr;
hgeRect *BBox;
HTEXTURE tex;
char *str;

Object(int _x, int _y, char *_imageFile)
{
x=_x;
y=_y;
str = new char[strlen(_imageFile)+1];
strcpy_s(str, strlen(_imageFile)+1, _imageFile);

tex = hge->Texture_Load(str);
spr = new hgeSprite(tex, 0, 0, 100, 70);
BBox = new hgeRect(_x, _y, _x + spr->GetWidth(), _y + spr->GetHeight());
}

Object(const Object &obj)
{
x = obj.x;
x = obj.y;
str = new char[strlen(obj.str)+1];
strcpy_s(str, strlen(obj.str)+1, obj.str);

tex = obj.tex;
spr = new hgeSprite(*obj.spr);
BBox = new hgeRect(*obj.BBox);
}

~Object()
{
//hge->Texture_Free(texture);//Вызывает ошибку
delete BBox;
delete spr;
delete [] str;
}

void Render()
{
spr->Render(x,y);
}
};
list
List;
Object *ObjectPtr;


2) В функции RenderFunc() при попытке нарисовать мои объекты из списка list опять же "Мистика" :-)
почему то fnt->printf(k+100, j, HGETEXT_LEFT,"x = %d\n y = %d",(*i).x, (*i).y); вызывает ошибку. Т.е. сам спрайт можно прорисовать только c помощью (1'). Данные класса созданные в конструкторе статически получаются не видны!!! Это при добавлении элементов в list!

bool RenderFunc()
{
hge->Gfx_BeginScene();
hge->Gfx_Clear(0);

int k = 100; int j = 100;
for(list
::iterator i = List.begin(); i != List.end();i++)
{
(*i).spr->Render(k, j); // (1')
//fnt->printf(k+100,j,HGETEXT_LEFT,"x = %d\n y = %d",(*i).x, (*i).y); //(2') ошибка
//(*i).spr->Render((*i).x, (*i).y); //(3') не нарисует
//(*i).Render(); //(4') не нарисует
k += 100;
}



hge->Gfx_EndScene();





return false;
}


В main, выделяя просто память под объект класса Object, при наличии в деструкторе функции hge->Texture_Free(texture); - работает норм

Если добавить так объект в список List.push_back(*ObjectPtr); //то Запускается нормально, но при выходе из проги завершается аварийно

если так List.push_back(Object(100, 200, "object.png")); добавить элемент в список, то сразу запускается с ошибкой.

3) Мне не понятно как происходит вызов деструкторов
В (1#)
Вызывается Конструктор

В (2#)
Вызывается Конструктор Копирования

В (3#)
Вызывается Конструктор
Вызывается Конструктор Копирования
Вызван Деструктор
Вызван Деструктор
Вызван Деструктор

Это происходит если не писать delete ObjectPtr; //(4#) По идее ведь, два раза должен вызываться деструктор для элементов находящихся в списке. А почему вызвался третий деструктор? Т.Е. с delete ObjectPtr; вызывается четыре деструктора.

Если так

int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
hge = hgeCreate(HGE_VERSION);

.
.
.
.

if(hge->System_Initiate())
{
ObjectPtr = new Object(100, 100,"object.png"); //(1#)
List.push_back(*ObjectPtr);//Запускается нормально, но завершается аварийно //(2#)
List.push_back(Object(100, 200, "object.png"));//Запускается с ошибкой //(3#)


hge->System_Start();

hge->Effect_Free(snd);
}


delete ObjectPtr; //(4#)



hge->System_Shutdown();
hge->Release();
return 0;
}
]]>
Завершение работы в полноэкранном режиме. http://relishgames.com/forum/index.php?p=/discussion/6408/zavershenie-raboty-v-polnoekrannom-rezhime. Sat, 09 Feb 2013 07:27:47 -0500 Emporio_1 6408@/forum/index.php?p=/discussions drawing Korean Alphabet http://relishgames.com/forum/index.php?p=/discussion/4290/drawing-korean-alphabet Mon, 06 Oct 2008 13:02:04 -0400 Neo 4290@/forum/index.php?p=/discussions Please understanding my bad english grammer.

Font tool makes only english alphabet.
How to drawing Korean Alphabet on HGE Engine?]]>
A China HGE Group http://relishgames.com/forum/index.php?p=/discussion/1641/a-china-hge-group Thu, 03 Aug 2006 18:09:14 -0400 Benwen 1641@/forum/index.php?p=/discussions ???“???«QQ????????14159676

We are welcome other friends ,if you jion us (China HGE Group),and you have a QQ num ,and you can join our QQ group:14159676,let's go !]]>