Showing posts with label develop. Show all posts
Showing posts with label develop. Show all posts

August 12, 2010

using interface in opengles(part2: functions)

In this parti’ll describe how you can run your interface on base of  game objects move.

Every code for running your game main windows,should be added in EAGLVIew class.

in opengles is better that you add more windows to games for performing menus and

games and etc but in this project it isn’t necessary .In project that we build before you

know that  ES1Rendere and ES2Renderer class have code for render engine in

opengles1 and opengles2 .All new Iphone device support opengles2.

Now we want control speed of colored box (see in previous project).we  add two lable

and  button to windows like this image

setspeedwin

Now we define two function increasespeed and decreasespeed and a lable with name label in EAGLView class.in EAGLView.h inside interface we add UILabel *label ;

then add

- (IBAction)increasespeed:(id)sender;
- (IBAction)decreasespeed:(id)sender;

after  interface definition Then linked two button + and – to them..Now we add some code in function .for example for decreasespeed function we add this code(is same for increasespeed )

   - (IBAction)decreasespeed:(id)sender {

label.text=@"increase";
    speed+=0.15f;
     [renderer setspeed:(speed)];
     [renderer render];// is necessary for seeing change

}

setspeed is function that should defined in ES1Renderer and ES2Renderer and

ESRenderer.in ES1Renderer and ES2Renderer after interface defination add

-(void)setspeed:(int)Speed; . do it for ESRenderer after @protocol defination.

Now in ES2Renderer.m and ES1Renderer.m add following code

-(void)setspeed:(int)Speed
{
    speed=Speed;
}

it is all you need. now see your app!

 

setspeedapp

Read more »

August 7, 2010

using interface in opengles (part 1)

in this tutorial  i’ll describe opengles template that using in game developing and add interface to it.You can use text and image and etc without any coding in iphone games.Just for more change in text and images in during  game you need coding. first we create new project in Xcode and select opengles template like this image

opengl  

then select name for project .i select “test” for my project you can select another.

Xcode opened window like this image for you that you see test project and folders of it.

testproject

As you see test have 6 folder (classes,shaders,other sources,resources,frameworks and products).In resource you can see MainWindow.xib (is main topic of post).Select window .You can add some text and images and other library .see this image

window

In opengles codes forced some change in main window after run it.With any code you

can change interfaces also .after run your program you can see this window like it.

labelopengl

i add label(my game 1)to opengles sample project that you see.you can chage font and size of text and others that you want.

Read more »

July 9, 2008

Download and develop your 3d java game mobile

For starting in programming with netbeans first I upload a sample java mobile game project that you can download it and run it or change it and even make a new game.

3d model making

1-for starting programming first you should have 3d model maker .this software should can export models to m3g.I using 3ds max 2008 but you can also use any 3d software like blender and a m3g exporter with it.Blender and m3g exporter are free.Maya is another good software for it but is not free.Every box and sphere you create in this software ,have an id in m3g that give you access to them and You can rotate and move this object .Graphics of this model maybe have some problem in

Some phones on base of their graphics.

Netbeans project information

2. After make your 3d model and export it now you are ready for programming .you should export your 3d model to subfolder "src\res" from your project folder .

My game engine is panel1 class and game canvas is "Canvas" and middle is hellomiddlet. 3ds model is in res folder (game1.max)with m3g file and you can change this model in way you want.your project name in netbeans is your project folder(unzip file after download) and you jar file is in dist folder.You can run it from mobile .In next post I'll explain my project functions and cods and models.

About functions and code

Panel1 class have two functions setmeshpositions and movemesh.setmeshpositions (15,35,35,35) means that your object with id 15 is positioned in 3 dimension space in xyz coordinate(x=35,y=35,z=35) and movemesh(15,"up",5) moving your object with id 15 to up direction in 5 unit.For example in this code

int state = getKeyStates();


if( ( state & DOWN_PRESSED ) != 0 ){


panel.movemesh(15, "up", 5);

state value is 1 when your using a key(in otherwise is 0) or no and DOWN_PRESS value say that you pressed down or

no and if two of them are true mesh move up 5 unit in up direction.you can change this code with replace up with down or like that.in next post I'll write some more about this codes and functions.

Download project now

Read more »