ComineGL: Game Library for Learning Programming in C/C++

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
panoramic
Posts: 6
Joined: Fri Jul 31, 2009 7:35 pm

Post by panoramic »

Tutorial7 demonstrates how to add collision detection.
Yes, but the zip points on tutorial #2.
macron12388
Posts: 126
Joined: Wed Sep 29, 2010 8:23 pm

Post by macron12388 »

slavik262 wrote:Trying to code a whole game without them will cause you to write way more code than if you used proper OOP technique.
:lol: You mean like trying to write a full game in Python? I don't even mean that wonderful blend of using C for the core and Python simply as an easy interface language, I mean, 90% Python, 5% some obscure Python graphics module with an OpenGL backend and 5% another proper input library. At first using Python LOOKS like you have to write less code, but then you realize the equivalent C/C++ amount of code would be very inefficient. ANY kind of interactive media project that you want to be fast, efficient, and powerful, you need to seek a language with a proper balance of low level computing power feel, yet also something that isn't requiring you to punch in machine code. I think C++ is that language, and it has proven it by being used for so many cool things over the years.
wahagn
Posts: 186
Joined: Sat Dec 06, 2008 5:11 pm
Location: Zundert (Netherlands)

Post by wahagn »

Hey,

I'm using your engine now and am really statisfied with the results the only minus is that you have made a lot of elemts but don't say anything about a lot of them on your site ( maybe becuase you haven't got time :?: ) so I came on the idea to help you ( if you agree offcourse :wink: ): I can
make turorials for your site about things you didn't describe yet, like how to set the WindowCaption and how to get a gun before the camera ( like in a FPS game) etc.

BTW: You didn't answer my question yet on if in the future you will be able to use the engine for 2d app purposes...??? :idea:
“Any code of your own that you haven’t looked at for six or more months might as well have been written by someone else.”
(Eagleson’s Law)
devetc
Posts: 22
Joined: Thu Nov 11, 2010 1:51 am
Contact:

Post by devetc »

wahagn wrote:Hey,

I'm using your engine now and am really statisfied with the results the only minus is that you have made a lot of elemts but don't say anything about a lot of them on your site ( maybe becuase you haven't got time :?: ) so I came on the idea to help you ( if you agree offcourse :wink: ): I can
make turorials for your site about things you didn't describe yet, like how to set the WindowCaption and how to get a gun before the camera ( like in a FPS game) etc.

BTW: You didn't answer my question yet on if in the future you will be able to use the engine for 2d app purposes...??? :idea:
Hi Wahagn,

I have not documented anything much, so as to work out the exact primitives that make it easy to program with. There are many functions that I have put into the library, but I am worried that if I document them too quickly then people will start using them before I get a chance to verify that they work well for someone learning to program for the first time.

I am assuming that someone new to programming will have only the
following(in increasing complexity):

1. Knows how to call functions
2. Knows basic datatypes and operations
3. Knows if statements
4. Knows for loop.
5. Knows an array
6. Knows how to write basic functions with return values

I think the library should be basic enough that anyone who knows 1-6
should be able to build some basic games.

I am currently working on a primitives for collision detection that you mentioned earlier. I do not like the way it is implemented right now. In the next release v0.13, I should have it working.

About the 2D purpose, I had envisioned the Animation Sprite Primitive just for that purpose. 2D animations will just be bill boards playing sprite animations in them. I would put up some examples for 2D sprites, but I am having difficulty finding sprites which I can use freely without fear of breaking someones copyright. (I really wanted to put up an example of a function playing an explosion, but finding an explosion sprite/sound which I can zip up into an example tutorial without fear of DMCA is difficult and time consuming).

Sorry for not responding so quickly. I am trying to put new code up while still maintaining a daytime job.
wahagn
Posts: 186
Joined: Sat Dec 06, 2008 5:11 pm
Location: Zundert (Netherlands)

Post by wahagn »

Ok, thanks for the reply

I have a question: Can I please help you with the game library :?: (with anything :D )
Last edited by wahagn on Wed Dec 01, 2010 4:45 pm, edited 2 times in total.
“Any code of your own that you haven’t looked at for six or more months might as well have been written by someone else.”
(Eagleson’s Law)
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Post by serengeor »

I can
make turorials for your site about things you didn't describe yet, like how to set the WindowCaption and how to get a gun before the camera ( like in a FPS game) etc. .
Not trying to be mean or anything, but he also didn't describe how to throw a grenade or how to shoot a gun or how to create enemies and also how to make them move, and how to make them attack you and much more!

Oh yea that was sarcasm, but seriously, these are the very basics you have to know before getting into programming 3d games/apps. Otherwise you'll get stuck on every part of your 'game', because you didn't know how to call a function or create a class, or position object in 3d space.

if you wan't to make tutorial how to position gun in 3d space thats ok, but it would be even better if you would make it more abstract, like positioning some kind of node(like cube) into 3d space, than maybe rotate an object around some point/node in the scene and so on.

PS. this project reminds me of dark GDK, which I would recommend to anyone thats starting to learn basic programming with c++
Working on game: Marrbles (Currently stopped).
wahagn
Posts: 186
Joined: Sat Dec 06, 2008 5:11 pm
Location: Zundert (Netherlands)

Post by wahagn »

Question 1


How can I make a code so I can move the camera with the WASD keys :?: :?: :?: because normally the library uses the arrow keys.

Code: Select all

bool Keys(void)
{


	if(CGLKeyIsPressed(CGL_KEY_W)==true)
		{

		???????????????????????????????????????
 
		}


	if(CGLKeyIsPressed(CGL_KEY_A)==true)
		{

		??????????????????????????????????

		}

    if(CGLKeyIsPressed(CGL_KEY_S)==true)
		{
		?????????????????????????????????? 
		}

    if(CGLKeyIsPressed(CGL_KEY_D)==true)
		{

		????????????????????????????????? 

		}


	return true;
}


/////////////////////////////////////////////
int main(void)
	{
	CGLEngine engine(400,400);
	
	CGLTaskLoad(100,50,true,Keys);

	CGLGameLoop();

	return 0;
	}



^^ Now I thougt of something like this, but I don't know what should be on the places where the question marks are? Someting like :

Code: Select all

CGLCameraSetActive(....);
CGLNodeSetPosition(....);
:?: :?: :?: :?: :?: :?: :?: :?:
Can you please help me?[/size][/b]





Question 2



BTW1: When do you think version 0.13 is coming out
????
















BTW2: you made a writing mistake on tutrorial 9 on the site ( not in the zipped code) :

Code: Select all

#include <stdio.h&gr;
schould be :

Code: Select all

#include <stdio.h>
“Any code of your own that you haven’t looked at for six or more months might as well have been written by someone else.”
(Eagleson’s Law)
devetc
Posts: 22
Joined: Thu Nov 11, 2010 1:51 am
Contact:

Post by devetc »

wahagn wrote:Question 1
How can I make a code so I can move the camera with the WASD keys :?: :?: :?: because normally the library uses the arrow keys.
Hi Wahagn,

To handle high performance movement, you need to process the raw keyboard events. It is missing in the library. I will put it in a future version. I wrote the current keyboard handler code for the library so that there would be a delay of 50ms between key presses of the same key, so that multiple keyboard presses would not be confusing to beginning programmers. To move the camera node, you need this high performance keyboard handler with no delays.

To get the position of a node is done by returning the position by
reference

Code: Select all

float x,y,z;

// Get Position of node 10
CGLNodeGetPosition(10,x,y,z);

//=At this point, x,y,z contain the position of the node
To set the position of a node you use

Code: Select all

// Set Positon of node 10 to x,y,z
CGLNodeSetPosition(10,x,y,z);

In the next release, I am adding the irrlicht animator idea as a basic primitive like node/sound/texture/.... I will be adding more animators
like gravity/ collision detection/velocity/rotation velocity...

Once these animators for velocity/rotational velocity are written, it should be much easier to write specialized camera movements.

The CGLCameraSetActive is used to switch between multiple cameras.
Try loading up two cameras and use a mouse press or keyboard press
to initiate a call to CGLCameraSetActive. For instance,

Code: Select all

    if(CGLKeyIsPressed(CGK_KEY_SPACE)==true)
        {
        // Set Camera Node 10 as active in viewport
        CGLCameraSetActive(10);
        }
When I get a chance i will put a tutorial for switching between camers.
wahagn wrote:Question 2: When do you think version 0.13 is coming out
I have been a bit busy this week--hopefully by sometime next week. When I get a chance to code, I usually commit large changes to svn repository. You can see some of the changes already for Animators...
devetc
Posts: 22
Joined: Thu Nov 11, 2010 1:51 am
Contact:

Updated Tutorial for an Explosions

Post by devetc »

Hello All,

I had a chance to download sounds/sprite sheet to demonstrate a tutorial for writing simple explosions.

http://comine.com/1622/tutorial20.htm

The tutorial demonstrates how to write a simple function which
renders an explosion animation with sound at different positions with the
cominegl library.

a screen snap shot is

Image


I am really grateful to the sprite/sound media developers who make these resources available for everyone(ie GPL/CCL/...). I do not think I could come anywhere close to the stuff that these guys make.
devetc
Posts: 22
Joined: Thu Nov 11, 2010 1:51 am
Contact:

Post by devetc »

wahagn wrote:
How can I make a code so I can move the camera with the WASD keys
Hello Wahagn,

I put in the raw keyboard handler that calls your callback function directly. I have not put the v0.13 in the download page yet, but you can download my test compiled library at

http://code.google.com/p/cominegl/sourc ... _v0.13.zip.

Just click on the view raw file.

(Or you can svn checkout the project and check out the release folder)

Here is an example code that you can try:

Code: Select all

#include <stdio.h>
#include <ComineGL/ComineGL.h>

//////////////////////////////////////////
bool HandleKeyboard(int keycode)
	{
	printf("Keycode=%d\n",keycode);
	
	if(keycode==CGL_KEY_SPACE)
		{
		printf("You Pressed the space bar\n");
		}

	return true;
	}


//////////////////////////////////////////
int main(void)
	{
	CGLEngine eng(400,400);
	
	
	CGLKeyboardSetHandler(HandleKeyboard);


	CGLGameLoop();

	return 0;
	}
See if you like the primitive function.

Any suggestions for changing function names/parameters or merging two or more functions into one would be greatly appreciated for the next release.

Thanks for the catching the errors on the website.

-devetc
wahagn
Posts: 186
Joined: Sat Dec 06, 2008 5:11 pm
Location: Zundert (Netherlands)

Post by wahagn »

Hey devetc,

If have tested it but I don't really see the diffrence, This time its working with keycodes but the principe is the same I think, Am I right? Now last time I was asking for how to make a code to move (walk) with the WASD keys and now you changed the method to detect key hits.... Can you tell me now how to make a code for the WASD keys??.. I mean not the part for detecting the key wich is pressed but the movement part. Let's say we have the following code:

Code: Select all

#include <stdio.h>
#include "include\ComineGL\ComineGL.h"

bool HandleKeyboard(int keycode) 
   { 
   printf("Keycode=%d\n",keycode); 
    
   if(keycode==CGL_KEY_W) 
      { 
      ? 
      } 


 if(keycode==CGL_KEY_A) 
      { 
      ?
      } 


 if(keycode==CGL_KEY_S) 
      { 
      ?
      } 

 if(keycode==CGL_KEY_D) 
      { 
      ?
      } 


   return true; 
   } 


////////////////////////////////////////// 
int main(void) 
   { 
   CGLEngine eng(400,400); 
    
    
   CGLKeyboardSetHandler(HandleKeyboard); 


   CGLGameLoop(); 

   return 0; 
   } 
What should be where the question marks are.. so I mean the code to let the camera move like you're walking...


I Guess something with animators, CGLAnimatorMoveTo()??
“Any code of your own that you haven’t looked at for six or more months might as well have been written by someone else.”
(Eagleson’s Law)
devetc
Posts: 22
Joined: Thu Nov 11, 2010 1:51 am
Contact:

Post by devetc »

wahagn wrote: Can you tell me now how to make a code for the WASD keys?
Hello Wahagn,

The coding for camera control using the keyboard handling and animators/tasks which I had originally envisioned seems to be too complex for beginning programmers. So, I have implemented a different set of functions for FPS camera control, until I can think of a better idea.

Code: Select all


#include <ComineGL/ComineGL.h>


//////////////////////////////////////////
int main(void)
	{
	CGLEngine eng(400,400);

	// Before you load a FPS camera, specify key mappings
	// These mapings will apply to all new FPS cameras 
	
	// Clear all existing Key Mappings (remove default arrow keys)
	CGLCameraFPSKeyClearAll();
	
	// Set one or more key mapings
	CGLCameraFPSKeyForward(CGL_KEY_W);
	CGLCameraFPSKeyBackward(CGL_KEY_S);
	CGLCameraFPSKeyLeft(CGL_KEY_A);
	CGLCameraFPSKeyRight(CGL_KEY_D);

	CGLNodeLoadCameraFPS(0);

	// Load and Move Cube 
	CGLNodeLoadCube(1,200);
	CGLNodeSetPosition(1,0,0,500);

	CGLGameLoop();
	return 0;
	}

I still have not released the v0.13 in the download page, so you need to get it svn or

http://code.google.com/p/cominegl/sour ... .13.zip.

Hope this works for you.

-devetc
wahagn
Posts: 186
Joined: Sat Dec 06, 2008 5:11 pm
Location: Zundert (Netherlands)

Post by wahagn »

Thanks, it worked for me, and now I can go further using the library.
And if you want me to help with the game library just say..

BTW: the link you gave didn't work but I was able to open the lib throug te link you posted on FRI 03 Dec ...

BTW: Does the library support mesh animation yet?And in wich version do you think yor gonna add 2d possiblities with the library I mean that it is possible to make 2d stuff(apps) with this game library ?
“Any code of your own that you haven’t looked at for six or more months might as well have been written by someone else.”
(Eagleson’s Law)
devetc
Posts: 22
Joined: Thu Nov 11, 2010 1:51 am
Contact:

Post by devetc »

Hello All,

I uploaded the version 0.13 cominegl library. You can download it at

http://code.google.com/p/cominegl

I added initial 2D animation features that wahagn mentioned. Since, I already used Animation for sprite animation, I called it an Action.

Collision Detection is done via Triangle Sets(called Triset). Sample below should explain basic code till I get a chance to write tutorials.

Code: Select all

#include <ComineGL/ComineGL.h>

//////////////////////////////////////////
int main(void)
	{
	CGLEngine eng(400,400);

	CGLNodeLoadCameraFPS(0);
	CGLNodeSetPosition(0,0,0,-100);

	// Load mesh 1 from sydney.md2
	CGLMeshLoadFile(1,"sydney.md2");

	// Load Node 1 with mesh 1
	CGLNodeLoadMesh(1,1);

	// Load texture 1
	CGLTextureLoad(1,"sydney.bmp");
	
	// Apply Texture to node 1
	CGLNodeSetTexture(1,1);

	// console all actions for mesh 1
	CGLActionPrint(1);

	// start sydney in running
	CGLActionPlay(1,"run");

	//*****************************************
	//*  Create a triangle set(Triset) for collisions
	//*****************************************
	CGLTrisetLoad(1);

	// Add triangle set of node 1 to triset 1
	CGLTrisetAddNode(1,1);

	// Start a collision response with camera node 0 and triset 1
	// 50.0 radius of collision and gravity=0.0
	CGLAnimatorCollisionResponse(0,1,50.0,0.0);

	CGLGameLoop();

	return 0;
	}

In the next release, I will add sprite operations for 2D.
devetc
Posts: 22
Joined: Thu Nov 11, 2010 1:51 am
Contact:

Post by devetc »

Hello Wahagen,

If you suggest operations for the cominegl library, I will do my best to implement them.

Thanks for trying out the library and commenting on it. One of the goals of the library was to make it easy to explore new functions by browsing the functions using context sensitive help and trying them out.

-Devetc
Post Reply