Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 19 Dec 2012
Offline Last Active Nov 27 2015 03:32 PM

Topics I've Started

Lua game integration

23 February 2013 - 05:31 PM

Hey guys. I've just integrated lua in my game (which isn't finished yet). Anyway, some things are bothering me.


I've registered functions a list of function pointers that I want to be able to call from Lua. It works fine. Although I feel like I'm making a facade between lua and my game and it requires (constant) changes to the code itself. I used lua as a logic for the debuff system in my game just to see what the scripts are all about. I'd basically implement the debuff logic inside the script, load it and execute it on an enemy. I started by making a facade class who's static functions would lua call and delegate the call to the enemy passed from lua to the engine.Something like this:


1.Debuff update

2.Call debuff script ( pass the enemy obj. to lua)

3.Debuff logic inside the script

4.Call the adapter class function (and pass the enemy if necessary).


Problem: writing function pointers for everything i want to be able to call from lua.


I'm pretty sure I'm doing something wrong, so it'd be better if I'd get on the right track from the beginning.


Thanks in advance



Convert between coordinate spaces

26 January 2013 - 04:50 AM

I'm trying to simulate a realistic camera in OpenGL ES, using iPhone camera and data received from gyroscope sensor. Basically when I
receive roll, pitch and yaw rotation from gyroscope I pass them to the openGL context and rotate every object in scene by minus of each angle, simulating the camera rotate.

// first object rotation/translation
CC3GLMatrix *modelView = [CC3GLMatrix matrix]; // cocos3D matrix

[modelView populateFromRotation:CC3VectorMake(-pitch, -roll, -yaw)];
[modelView translateBy:CC3VectorMake(0, 0, -distance)];
glUniformMatrix4fv(_modelViewUniform, 1, 0, modelView.glMatrix);
// draw object
// second object rotation/translation
CC3GLMatrix *modelView2 = [CC3GLMatrix matrix];
[modelView2 populateFromRotation:CC3VectorMake(-pitch, -roll-30, -yaw)];
[modelView2 translateBy:CC3VectorMake(0, 0, -distance)];
glUniformMatrix4fv(_modelViewUniform, 1, 0, modelView2.glMatrix);
// draw object

And it works just fine. The problem is that iPhone coordinate system rotates with the phone, so for example roll is always "hitting" the sides of the phone. So when I add another object, alpha degrees to the left/right, it becomes the left/right of the iPhone coordinate system, not the world coordinate system.

The first image is with no rotation, looking ahead.




But when I rotate the phone to the right by around 30-40 degrees, the objects' sides are no longer parallel and its obvoius that coordinate axis are bound to the device.




As the phone is inclined to the right, so are the objects, and the only difference in objects positions is -30 in roll.


Is there a way to convert these coordinates to the world coordinates or any other way to rotate the whole scene?

Quality of a sprite based game

02 January 2013 - 02:47 AM

Hey guys. I'm almost done writing a framework for a game. Making a 2D game, I've read some material on the web and realized two options I have are making it sprite based or doing it in 2D projection in OpenGL, since I'm targeting windows, android and iOS. I've decided to go with sprites for the initial version but I'm a bit worried of the graphics quality that can be achieved with sprites. I'm sure there are nice examples of sprite games that look awesome, but there's a buzz in my mind about it. "Sure you can achieve awesome looks with sprites" you would say, but my definition of awesome might differ from yours. I picked sprites over OpenGL because of animation simplicity and actually simplicity overall. I want to start small and not get caught in something I can't get out of, since I'm doing the whole game myself. So... What should I expect from sprites regarding quality(looks)?