Showing posts with label programming. Show all posts
Showing posts with label programming. 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 3, 2010

Introduction to iphone programming

Xcode is  best tool for Iphone and Ipad and Mac programming.You can used so
many interfaces  easily in programming and connect them to source as you
want also with simulator for test your apps.see here for more info.In this picture
you see xcode 3.2.3 ide with iphone sdk 4.0
xcode3.2.3

Every project in Xcode at last have one windows(or view) .In windows we can
add some library like button,label,slide and…For this purpose we should
expand resource folder in left sidebar and open MainWindow.xib or
MainView.xib .Interface builder tool opened and show a blank window.It is
same windows that you see in iphone app. next drag your library from right
side to your windows . If you can’t see library should select tool menu and
then library.
interfacebuilder
Now build and run your apps .In next post I'll describe opengles tempelete that
is best choose for create 3d games for Iphone .and show how using interface
builders and codes in Xcode. 
yourapp1
Read more »

July 24, 2008

Using pointer: download A sample pointer enabled killer game

I add a sample project for more discuss in light and cameras. it is only a camera moving in between walls(textures are from internet).I'll add gun and other effects to it in next time.You can also edit 3d model in way you want. This is my model in 3 direction:top,camera,left and perspective


This model have a camera and 3 light and you should draw your model on base of your camera(upper right picture) and if you want use another cameras also you should configure your model on base of them. In this model camera id is 14 and for loading camera in program this code is enough

Camera camera;

Camera=(Camera)(Myworld.find(14));

Camera position in this model is your person eye.You can move camera in every place with this code

m.setTranslation(x,y,z);

For example you can move it with pointer with this code

protected void pointerPressed(int x, int y) {

m.setTranslation(x,y,z);


}

Pointerpress is a function that invoked when a pointer pressed and x,y is pointer location in screen .You can say that when pointer pressed (x,y) location in screen camera can move.you can add image and text to game for this purpose also. In next post i add text and image to this project for getting better result from this project.

Download project

Read more »

July 16, 2008

Advanced programming I: lights and cameras

1.your 3d model

In every game you should select your lights and cameras carefully and move them on base of your objects moves specially in 3d games.

In this 3d model you see three light( free spot) and one camera and panel and ball(sphere).this is a sample game for moving a ball in panel.For using it you should export in m3g After do that maybe you see a view such this in a m3g player

As you see you may lost some graphics on base of your m3g exporter and your 3d software now you are ready for moving your lights and cameras.

2.moving your lights and cameras

Java have two class for moving light and cameras in m3g files with name Light and Camera.

For moving light and cameras you can use this codes

Light l=(Light)(Myworld.find(lighted);//getting your desired light

l. setTranslation(x,yz);//move it to x,y,z location

Camera m;m=(Camera)(Myworld.find(cameraid);//get your desired camera from your world

m.setTranslation(x,y,z);// move it to x,y ,z location

now you can run your game in netbeans emulator (see picture)but you should now that your game maybe presented in mobiles differently on base of their graphics.

You can send your comments about this post .I'll be glad for them.

Read more »

July 1, 2008

About middlet and gamecanvas

Midlet

When you start to programming with java for mobile ,first class you build is midlet .Midlet is an interface between you and mobile. In netbeans you can easily add midlet automatically or with right click in project and in new menu click in visual midlet. In visual midlet you have a form by default and actions belong to it and in graphical interface you can easily add text or other thing to form but if you dont wnat to have form in your program you need only midlet.This class have functions like startApp,destoryApp,startMidlet and like .This function say's what you want to do when midlet started or your program started and etc.In middle you can also switch display of your program between graphics and forms that you make or add your command to your program. It is better that you have this class and game canvas and game engine in different file. It give your program better readability and of course better performance.You can use your game engine in other programs and your game canvas in other midlet and many other features.

Your game engine can also contains more class in base you programs.

__________________________________________________________________________________

Gamecanvas

In mobile programs you have also a gamecanvas (midpcanvas) class.This class contain function for pressing or dragging or clicking keys or pointers and you can add your functions to them.it is an example

protected void keyPressed(int keyCode) {

int action = getGameAction( key );

switch(action)

{

Case DOWN:

MOVEDOWN();

.

.

.
}

}

DOWN,UP,RIGHT,LEFT are predefined value's in gamecanvas class and their value is same with returning value from getGameAction(key) when you click down ,up,right and left key in mobile.

A game canvas also has paint function .With paint and repaint function you can draw your graphic world(you'll learn about it in following posts) .You can change your graphics world everywhere and repaint it everywhere also.But you should know more repaint in bad place in class forced to some problem in your game graphics .

With this primary information you are almost ready for start programming .

Read more »

June 20, 2008

java mobile game programming

nowadays mobile game's are popular in world.why?Because mobile user's are increasing and ofcourse their user are different. from child's to young , from businessman's to unemployed people's .But everyone need game and music's for some funs in their tiring times specially young people's. In past time's game are limited in mobiles.Because Mobiles have limited memory and graphics but todays mobile have more memory and graphics and we can make better game .New game have 3d model's and high quality sound's that give user real world .Our focus in this blog is in 3d java game programming in mobile and how do it.I'm waiting for your comment about this blog and which content you need for mobile programming.
Read more »