General http://relishgames.com/forum/index.php?p=/categories/general/feed.rss Sun, 19 May 13 17:49:57 -0400 General en-CA 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; // Works OK
DWORD myint2; // Works OK

]]>
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?]]>
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
]]>
Assembly question http://relishgames.com/forum/index.php?p=/discussion/6396/assembly-question Fri, 07 Dec 2012 08:56:42 -0500 SantalLican 6396@/forum/index.php?p=/discussions - Very low executable size (lowest : 4 bytes) - Wow...
- Maximum speed and optimization.

So I decided to learn it immediately, and I will write my own assembly program using HGE game engine. Is it possible? :)
I downloaded an assembly software and then, I like it, but it seems this tool is missing some necessary features. They are : Includes (limited), File code browser, function hint, workspace,...

How do you fell about this? And, do you know (a good assembly program)? Share with me and any help would be greatly appreciated. :)]]>
DirectSound help http://relishgames.com/forum/index.php?p=/discussion/6394/directsound-help Thu, 29 Nov 2012 07:49:49 -0500 SantalLican 6394@/forum/index.php?p=/discussions Currently I want to...upgrade my hgeAVI project. Actually I'd like to hear some sounds from my own HGE AVI project because? I am now going to introduce some game video trailers... :)
I overheard that using DirectSound instead of standard API functions certainly will completely solve this problem. But I've tried many searches and I could not find the exact place so far...

Does anyone know? (Any help would be greatly appreciated.)
:)]]>
Linking problem ? http://relishgames.com/forum/index.php?p=/discussion/6365/linking-problem-s Wed, 24 Oct 2012 10:30:24 -0400 SantalLican 6365@/forum/index.php?p=/discussions
I downloaded DirectX 8 from your suggestion link, installed it and re-compilied HGE project with DX 8 libraries, and results :
- HGE compiling & linking : 0 error(s), 0 warning(s) (Good)
- All HGE programs work properly, no errors, no crash messages,... (Good)
- No linking errors from HGE static library. (Good)
- Incorrect output file size [oh no, it gets higher than 700 kilobytes] (?????)

It's really horrible ! The weight of standard HGE dynamic-link-library (dll) is only 150 kb, and mine is about more than 4x !

Does anyone have any method to reduce the HGE dll size ? (I currently can't apply my changed HGE for my own projects...) (:]]>
HGE Google Search/Compromised http://relishgames.com/forum/index.php?p=/discussion/6390/hge-google-searchcompromised Wed, 14 Nov 2012 23:59:29 -0500 losinggeneration 6390@/forum/index.php?p=/discussions

This site may be compromised.[2]
Tramadol Online Without Prescription. Tramadol Pills Without
Prescription. Tramadol Online Without Prescription.


You may want to check your servers for compromises.

As another point, both contact emails I could find on relishgames.com (info@ & support@) returned with: Recipient address rejected: User unknown in virtual alias table (state 13). That might be useful to fix as well while you're looking into the other issue.

[1]https://www.google.com/search?q=hge+relish+games
[2]http://support.google.com/websearch/bin/answer.py?hl=en&ei=ggekUO2yNubM2AXE2IDgCQ&answer=190597&?sa=X&ved=0CDkQpwgwAA]]>
Hey all i have Questions to Extension http://relishgames.com/forum/index.php?p=/discussion/6384/hey-all-i-have-questions-to-extension Sun, 04 Nov 2012 07:35:28 -0500 laguz 6384@/forum/index.php?p=/discussions
Ok. to the point,
Simple. i want what do u using extension for Private Data?]]>
Bug ?? http://relishgames.com/forum/index.php?p=/discussion/6379/bug-ss Thu, 01 Nov 2012 02:22:08 -0400 SantalLican 6379@/forum/index.php?p=/discussions I replaced the hge library, dll with the original one, but I caught this error again !
Perhaps I can't execute MessageBox ?
My test code :
if (hge->Input_GetKeyState(HGEK_ESCAPE)){MessageBox(0,"Game Exit !","Message",0)
return true;}

Only a MessageBox call can cause game collapse ! Why this problem appear ? !?? (; And how to solve it...]]>
FontEffLoader source library launched ! http://relishgames.com/forum/index.php?p=/discussion/6375/fonteffloader-source-library-launched- Mon, 29 Oct 2012 10:09:10 -0400 SantalLican 6375@/forum/index.php?p=/discussions
This is FontEffLoader source library, which contains XML sources for FontEffLoader
Have you done any XML source yet ? Share with us and everybody the most beautiful loader sources and then discuss !
]]>
FontEffManager - Examples http://relishgames.com/forum/index.php?p=/discussion/6362/fonteffmanager-examples Sun, 21 Oct 2012 17:22:58 -0400 SantalLican 6362@/forum/index.php?p=/discussions Here are some samples & tutorials which are done by FontEffManager.
Now, enjoy !

1- Programs :
1. HgeNotepad : http://relishgames.com/forum/index.php?p=/discussion/6351/hgenotepad-
2- Samples :
1. Animated edit mode example : http://relishgames.com/forum/index.php?p=/discussion/6346/my-first-effect-idea-#Item_6
3- Tutorials : (Comming soon)]]>
FontEffManager (Initiating (Part 1)) http://relishgames.com/forum/index.php?p=/discussion/6361/fonteffmanager-initiating-part-1 Sat, 20 Oct 2012 03:38:26 -0400 SantalLican 6361@/forum/index.php?p=/discussions
Remember : The default (NULL) value of float parameters is Null.
(Before compiling : Check hgefont.h make sure the header is newest (Copy from "Example\includes")

1. Initiating
FontEff (TextEx) is a hgeGUIObject. So you must attach initiated object with a hgeGUI. You should make it visible in everywhere.
Syntax : FontEff(int Id,hgeFont *,float x,float y,float w = Null,float h = Null,bool PageMode = false,int nSize = 1024);
Parameters :
hgeFont * fnt : Pointer to a hgeFont object.
x, y : X-Y Position of this object.
w : Width of TextBox (Null : Ignore (Unlimited))
h : Height (Null : Ignore (Unlimited))
PageMode : Enter Page mode or not (Cursor appears, and some edit keys is allowed)
Otherwise : Keep default information (You can still edit text (limited)) See (SetTextMode())
nSize : Size of character buffers. Default is 1024. (1024 characters total))

Basic, fast method :


//FontEff *Txt;
TextEx * Txt //TextEx object

int WinMain([...]){/*...*/ if(hge->System_Initiate()){//gui = new hgeGUI(); hgeFont * fnt = ...
////////////////////////////////////////////////////////////////////////////////////////////////
gui->AddCtrl(Txt = new TextEx(1,fnt,100,100)); // Fast method ?
////////////////////////////////////////////////////////////////////////////////////////////////
//Do more....
}}


Tip : FontEffManager includes FontLoader class which can load multiple fonts directly without search & load font(s) from file.
Remark : Maybe a little slow, but very powerful.

////////////////////////////////////////////////////////////////////////////////////////////////
FontLoader *fntLoader = new FontLoader("[..Font name..]"); //Verdana, Arial, etc,...
////////////////////////////////////////////////////////////////////////////////////////////////
gui->AddCtrl(Txt = new TextEx(1,new hgeFont(fntLoader->vChars,fntLoader->GetTexture()),100,100)); // Fast method ?
//Do more....
delete fntLoader;


Basic, instant method :
FontEffManager includes FontEffLoader class and it's fully-functional. It saves your time and makes everything is clear. So you must know at least some knowledge of this "language".
Simply, tell the class Xml file name and where your source is.

Note : Some Xml files have multiple root tabs (Source or other tabs) and they are invalid. So maybe this tool can require an another information (Default Root-XML) - to access the sources if they are not existed.

Parsing functions syntax :

1 - char ReadFile(const char * FileName,const char * Source,INFO::subInfo *Temp = 0,INFO::subColorInfo *colTemp = 0);
2 - char ReadFile(const char *,const char *,enum z_TypeInfo Type,INFO *Info);
3 - char ReadFile(const char *,const char *,const char * Target,INFO *Info);
4 - bool ParsingFile(const char *,const char *,INFO *infoTarget,bool bInit = false);
5 - bool ParsingFile(const char *,const char *,TextEx * Txt,bool bInit = true, bool bInitChild = true);

Same information : const char * FileName, const char *Source.
And compare : ((1) - (2) - (3)) < (4) < (5)
Speed : (1) > (2) - (3) > (4) > (5)


////////////////////////////////////////////////////////////////////////////////////////////////
TextExLoader * txtLoader = new TextExLoader ("Xml"); //Root XML (if necessary)
////////////////////////////////////////////////////////////////////////////////////////////////
FontLoader *fntLoader = new FontLoader("[..Font name..]"); //Verdana, Arial, etc,...
gui->AddCtrl(Txt = new TextEx(1 ,new hgeFont(fntLoader->vChars,fntLoader->GetTexture()),100,100)); // Fast method ?
txtLoader->ReadFile("test.xml", "Scale-Init", mScale, &Txt->info); //Use function (2)
txtLoader->ReadFile("test.xml", "Scale-Init", "mScale", &Txt->info); // Use function (3)

//Do more....


Create a FontEffManager is very easy ! You'll see everything is clear, no complex variables or structures...
Continue...]]>
FontEffLoader class (Part 1 - Some important functions) http://relishgames.com/forum/index.php?p=/discussion/6359/fonteffloader-class-part-1-some-important-functions Fri, 19 Oct 2012 09:38:24 -0400 SantalLican 6359@/forum/index.php?p=/discussions
Okay, I introduce FontEffLoader's data :
Data of FontEffManager look like as source code. (XML Format). You can :

Sum, Subtract,..(Calculate);
SetMath(), SetTime(),... (Functions);
If-While-For (Condition);....

I switched from Ini-File -> XmlFile to make the source data look more modern and more easy to edit.

Common elements :
Command : Execute a command
Param : Parse a parameter

Common command syntax : <<Command = "name" [...parameters...]/>> (Sorry for formating tag (avoid text losing in HTML format))

And here, some (important) functions :

1 - Commands (Calculating)
Syntax : <<Command = "name" [...parameters...]/>>

name : Sum, Subtract, Multiply, Divide, Equal, Math, Minus
parameters : Sum, Subtract, Multiply, Divide, Equal, Math : require parameters "target" & "value".
Exceptions :
Minus : Only requires "target" parameter.
Math : Requires more, "type" parameter. Look likes Math functions : (sin, cos, floor, fabs, pow, sqrt)

My example :








<<Command name="Multiply" target="fVal" value="-2.0f"/>








2 - Log (variable or string)
Two cases :







3 - Insert-Var command (very useful)
Syntax : <<Command = "Insert-Var" var-name="[...]" value="[...]"/>>
value : Optional








4 - If-While-For
Parameter :
compare : Can be (greater, greater-equal, lower, lower-equal, equal, not-equal)
Like as ( (>) | (>=) | (<) | (<=) | (==) | (!=)) (Sorry, some symbols are not allowed in XML format)<br />While : Comparing parameters are optional.
IF-WHILE-FOR Condition :





























5 - Break - Halt functions
Break : Stop parsing command (Not useful).
Halt : Stop parsing immediately. (You can show why the parsing halted is)

Mmm... : An example code :












And about loading it :

TextEx *Txt = new TextEx([...]);
//Init TextEx object...
/////////////////////////////////////////////////
TextExLoader *txtLoader = new TextExLoader();
//Start parsing...


World of parsing functions :
0-> ReadFile (Specific source with temporary variables)
1-> ParsingFile (*INFO) (Multiple sources and public variables support)
2 -> ParsingFile (*TextEx) (Multiple times parsing with multiple sources and public variables support (Only initiate once))]]>