Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Game Development

Reply
 
LinkBack Thread Tools Display Modes
Old 02-10-2011, 04:52 PM   #1 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 9
dilideskon is on a distinguished road
Default Creating the base of an iPhone game (OpenGL)

Hi,

I'm a C--/Java programmer, not necessarily very experienced.
I mainly created GUI-based applications and this is my first time trying to make a game, or an application that is constantly in a loop.

I've looked for about a week trying to figure out how I should start with, but most of them are dated, looking totally different from the template I start with when I create a new project on Xcode.

I can start programming on my own when the base is complete, so I really want to ask for your help on the start.

I'm trying to make a 2D game using OpenGL ES 2.0. As this is my learning experience, I wish not to use other engines like Cocos2D. My template is an OpenGL ES application and I would like to start from it.

I just want to ask few questions. I'm pretty sure this is nothing for experts so please help me get through this...

Here is what my application would look like, but I have no idea where and how I should implement following algorithms into the template.:

//I have no idea where I should put this piece of chunk:
superclass.gameLoop
{
currentGameState.manageUserInput();
currentGameState.controlGameLogic();
currentGameState.render();
drawRenderedGraphics();
}

Where do I put that algorithm?

There are ViewController, EAGLView and AppDelegate. In which one and what method should I start putting my main code like gameLoop?

How do I use UI objects into OpenGL view?
For example, I would like to do all the drawings on OpenGL, but since it's a game I need to put buttons and other UI objects into the screen.
I tried putting the following code:

UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = CGRectMake(100, 170, 100, 30);
[button setTitle:@"Button" forState:UIControlStateNormal];

into - (void)drawFrame from TestAppViewController.m, but I know it's wrong.
If I add that code into like "- (void)viewWillAppearBOOL)animated", the button will be functional, but there would be some cases that I will draw images on them.
Also how can I animate them, like moving their coordinates?

My game will have different states (or game screens) which will function differently.
Each state will have a class of its own in a following structure:

//Each state will inherit this class.
gameStateClass
{
- render
- controlGameLogic
- manageUserInput
}

I know what AppDelegate does, but I'm not sure where I should put all the codes that should be in the super class.
Like current game state information, changeState method and all those kinds of things.
Do I usually need one ViewController if I'm going to have different states or is it something that I need it for each view (state)?


I've read a lot of documents, books and even the Apple Developer Library, but I couldn't understand it clearly.
Sorry I have many questions, but it would be SO GREAT AND THANKFUL if anyone can help me through this.
Thank you so much in advance.
dilideskon is offline   Reply With Quote
Old 02-10-2011, 05:17 PM   #2 (permalink)
Registered Member
 
headkaze's Avatar
 
Join Date: Feb 2010
Posts: 359
headkaze is on a distinguished road
Default

Your main game loop is drawFrame in TestAppViewController.

Generally for a game you will break your game into an update and render function.

Here is my main loop:

Code:
- (void)drawFrame
{
	if(paused)
		return;
	
	[renderer update];	
	[renderer render];
}
headkaze is offline   Reply With Quote
Old 02-10-2011, 06:05 PM   #3 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 9
dilideskon is on a distinguished road
Default

Quote:
Originally Posted by headkaze View Post
Your main game loop is drawFrame in TestAppViewController.

Generally for a game you will break your game into an update and render function.

Here is my main loop:

Code:
- (void)drawFrame
{
	if(paused)
		return;
	
	[renderer update];	
	[renderer render];
}
What should render and update method do?
Do you ever need EAGLView? What does this class do?
dilideskon is offline   Reply With Quote
Old 02-11-2011, 08:43 AM   #4 (permalink)
Registered Member
 
Join Date: Nov 2009
Location: Chicago
Posts: 29
DaveM is on a distinguished road
Default

Quote:
Originally Posted by dilideskon View Post
What should render and update method do?
Do you ever need EAGLView? What does this class do?
Update is where you move/update your game objects, render is where you draw them. May want to check out the following:

OpenGL Game Programming
DaveM is offline   Reply With Quote
Old 02-11-2011, 09:34 AM   #5 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 9
dilideskon is on a distinguished road
Default

Quote:
Originally Posted by DaveM View Post
Update is where you move/update your game objects, render is where you draw them. May want to check out the following:

OpenGL Game Programming
Thanks so update is actually when you put game logic and manage input?
dilideskon is offline   Reply With Quote
Old 02-11-2011, 10:13 AM   #6 (permalink)
Registered Member
 
Join Date: Nov 2009
Location: Chicago
Posts: 29
DaveM is on a distinguished road
Default

Quote:
Originally Posted by dilideskon View Post
Thanks so update is actually when you put game logic and manage input?
I actually use a separate handleInput function...

Another good source is NeHe Productions: Main Page
DaveM is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 423
9 members and 414 guests
7twenty7, chemistry, ChrisYates, hussain1982, Retouchable, skrew88, SLIC, walex, xzoonxoom
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,679
Threads: 94,128
Posts: 402,921
Top Poster: BrianSlick (7,990)
Welcome to our newest member, xzoonxoom
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:10 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0