2d gaming on the iphone [need help getting started]

Apprentice
Posts: 5
Joined: 2009.07
Post: #1
Hello,

So for some time I've been trying to develop a game for the iphone. So far all my attempts have led to me pulling my hair out on forums and tutorialMad.

So after pulling my hair out, it looks like I'll be resorting to OpenGL to solve my problems.

Basically I want to create one of those simple side scrolling shooter games (the ones where you control a plane from a over head view and shoot your enemies down). The unique thing with this game is that there is some sort of depth to it, but it will all involve 2d images (png image files). So to depict depth, the image will be drawn at an angle to illustrate the plane being tilted. So it's going to be paper mario-ish in nature.

As for what I know, I've created similar games before using java and Graphics class. So if you can connect using OpenGL to that, it would greatly help me with this stuff.

Anyway, I'm sick of reading confusing tutorials so could someone give me a simple example to go off of, that would help. I basically want to try the monkey see, monkey do approach to this.
Quote this message in a reply
Member
Posts: 306
Joined: 2009.03
Post: #2
You can also accomplish depth using parallax scrolling. Taking the glsprite example and dumping the Texture2D class(google it) you can pretty much get right into having images drawing and then from there you just make your game.
Quote this message in a reply
Apprentice
Posts: 5
Joined: 2009.07
Post: #3
kendric Wrote:You can also accomplish depth using parallax scrolling.
Well what I mean is to make the image itself slanted so it makes the player look like they're tilted to the right or left.


kendric Wrote:the glsprite example and dumping the Texture2D class(google it) you can pretty much get right into having images drawing and then from there you just make your game.

Quite frankly I'm completely lost.... when I google that stuff I'm not getting stuff a beginner such as myself would understand. Quite frankly I just recently got a mac, I know how start a project and use interface builder, but that's about it. I understand the philosophy of how design a 2d game.

I need a really simple tutorial that simply does this: 1.) this is how you set up the environment, 2.) this is how you load an image and 3.) this is how you draw the image.

Just keep in mind what I said before:
Quote:I'm sick of reading confusing tutorials so could someone give me a simple example to go off of, that would help. I basically want to try the monkey see, monkey do approach to this.


Right now I'm really frustrated with this. I have spent WEEKS! on this and I'm sick of it. For some reason I can't get a simple answer for this simple task. In Java I can have a simple game as this done in a week and now I can't even get an image up.
Quote this message in a reply
Moderator
Posts: 3,571
Joined: 2003.06
Post: #4
MR_UNOwen Wrote:Right now I'm really frustrated with this. I have spent WEEKS! on this and I'm sick of it. For some reason I can't get a simple answer for this simple task.

1) This *isn't* a simple task. OpenGL has a notoriously steep learning curve.

2) After this last year of new iPhone developers seeking their riches (some of them simply cutting/pasting code and even going so far as to call that code their own), many of us are just plain tired of helping sometimes. Sad

There are several tutorial sites out there for iPhone, so it'd be nice if you listed the ones you've tried and couldn't figure out. In the meantime, you can try this one I suppose.

I know you've spent WEEKS! on this, but it does take some time. It took me MONTHS! to figure out the basics of OpenGL when I started, way back when... and I still don't know a whole lot about it.

Quote:I need a really simple tutorial that simply does this: 1.) this is how you set up the environment, 2.) this is how you load an image and 3.) this is how you draw the image.
Apple's GLSprite sample code does those three things, but there is no tutorial to go along with it.
Quote this message in a reply
Apprentice
Posts: 5
Joined: 2009.07
Post: #5
Well I can understand how some one such a myself can be annoying, but I'm just flat out lost. BTW I just recently switched to OpenGL to make my game. I was last trying using Quartz and some one gave me this link which really didn't help. What driving me nuts is that after so much time spent, I've learned nothing.

Well I'm taking a look at it now. Anyway, if it's not too complicated, it would be nice if I could get a simple explanation of how everything fits together in the abstract. For example in Java, everything in the window is an extension of a Component class and when each component is to be drawn, it's paint method is called and is passed a Graphics class to draw what ever it needs. Is there some simple relationship I can understand how OpenGL fits in with everything else. Is it it's own layer and other components can go over and under it (like buttons) or Does it just take over the screen.

--------------------Update--------------------------------------------------------
Well I just ran into some sample code that may help..... If it does I'll post it here for anyone else that's in my situation. Hope it works.... ^_^
Quote this message in a reply
Moderator
Posts: 3,571
Joined: 2003.06
Post: #6
MR_UNOwen Wrote:What driving me nuts is that after so much time spent, I've learned nothing.
Ah, I see, you're new to this programming thing Rasp

I kid, but not really. Rasp

No seriously though, I've found myself thinking that same thing countless times over the last twenty years. Honestly, if you feel like you know what you're doing, you aren't learning anything. Wink

This stuff can be HARD to learn, and you can be spinning your wheels forever before something takes hold and you can run with it.

MR_UNOwen Wrote:Is there some simple relationship I can understand how OpenGL fits in with everything else. Is it it's own layer and other components can go over and under it (like buttons) or Does it just take over the screen.
Yeah, you can look at it like it's its own layer. OpenGL is just a library to abstract away the complexities of the graphics acceleration hardware. As such, it doesn't do things like make buttons or text; (mostly) only the bare basics, like rasterizing geometry and texels and manage VRAM. OpenGL is unfriendly and spartan to folks who expect lots of conveniences like DrawButton(x, y, width, height). It's bare-bones to many programmers, and is rather low-level in that sense.

Basically, with OpenGL, expect to "roll your own" for most of the stuff you might expect. While that sounds kinda sucky, once you get a grasp of what OpenGL actually does for you behind the scenes, it's really rather convenient Wink
Quote this message in a reply
Member
Posts: 166
Joined: 2009.04
Post: #7
MR_UNOwen Wrote:Hello,

As for what I know, I've created similar games before using java and Graphics class. So if you can connect using OpenGL to that, it would greatly help me with this stuff.

Anyway, I'm sick of reading confusing tutorials so could someone give me a simple example to go off of, that would help. I basically want to try the monkey see, monkey do approach to this.

Well, it if you really want to just make games then perhaps going with a 3rd party library would be a more sensible solution than trying to reinvent the wheel.
There are quite a few available - for instance Cocos2d and others ..

Like AnotherJake said, OpenGL tends to be a complex beast because , for best results, it essentially requires you to take over and manually handle everything related to display.
That's why there are 3rd party engines available.
It took me about 5 months to come up with my own engine ( and I was already quite familiar with OpenGL to begin with) so it takes a lot of time.

BTW.

I will be releasing my engine, the complete source code and a bunch of demos/examples.
Currently I am working on a game based on the engine , once it is done , I will release everything.
Here are some videos (I am still l learning how to use screenflow so the videos are not exactly production quality, and being currently served on my home box, download speed might a tad slow - I should probably host them elsewhere)

The game:
http://www.warmi.net/tmp/anigmarec.mov

or at lower quality at youtube:

http://www.youtube.com/watch?v=GhekKNJVEuM

A "concept of proof" sort of demo for the engine:

http://www.warmi.net/tmp/stonedemo.mov


2d demo ( bunch of animated sprites + various color/blending effects) :
http://www.warmi.net/tmp/Demo2d.mov

And here is one for the GUI part:

http://www.warmi.net/tmp/DemoGUI.mov


Everything runs at about 40-30 fps on the first gen iTouch.
Quote this message in a reply
Member
Posts: 306
Joined: 2009.03
Post: #8
This is not to sound harsh, but just to help you out to make sure you are going the right direction. The complication factor in iphone programing is high enough that if you are unable to take nice sample codes and plug them together, you are likely not at the required skill level to have a good chance of making it through the entire app development cycle. It might make more sense to do some basic programing classes to get more comfortable with programing in general and then come back and try again.
Quote this message in a reply
Apprentice
Posts: 5
Joined: 2009.07
Post: #9
Good news... I'm starting to figure things out. That sample code is paying off. LOL Wink Rasp Rolleyes Grin

Anyway... now I got a bunch of conceptual questions...

So the sample code I was looking at was this.

1) So... looking at EAGLView.m is this what happens: load the image/ get the attributes/ draw it to the buffer/ each time the timer goes off, clear the screen, rotate what's in the buffer and draw to screen?

2) I noticed there's a frame and render buffer. I understand the basic concept of buffer, but what does each do in contrast to the other in this case?

3) What's a texture in terms of OpenGL?

There's a bunch of other questions I have, but I'm sure I can figure it out by myself.

warmi,

That's really cool, I may use that engine in the future. Love
Quote this message in a reply
Apprentice
Posts: 5
Joined: 2009.07
Post: #10
OK.... I'm back to square one again.... well... at least I know how to load an image.

So I'm following the GLSprite example from this link. I can understand a good portion of it, but I'm having trouble understanding the individual components that make up drawing the image to the buffer. I can see that it draws it to the buffer thats the size of the image and then just rotates the buffer each time. I purchased a book on opengl es 2.0, but I'm even lost with all the technical jargon in that book.

Could someone simplify what's going on in that example code? I really want understand what's going on in this example. I'm particularly confused with the set up.

Also I tried playing with code by translating the image in one direction after the call to rotate the image, but the image ends up spinning in a circle rather than in place as it moves to one side of the screen.

I'd really appreciate any help to learn how to use Opengl. Blink
Quote this message in a reply
Nibbie
Posts: 1
Joined: 2009.08
Post: #11
I'm looking down the same rabbit hole as you are man, believe me. I understand even less than you, but I'm absorbing as much as I can.

A really good tutorial that I've come across is here: http://iphonedevelopment.blogspot.com/20...le-of.html

Hope this helps
Quote this message in a reply
Member
Posts: 60
Joined: 2009.06
Post: #12
I use quartz for my 2D game...I managed to get it to run almost smoothly on my device, I posted some tips in my blog which is the link in my siganture.
Quote this message in a reply
Member
Posts: 65
Joined: 2009.03
Post: #13
I've got a blog where I've been posting video tutorials on creating a 2D iPhone game. As I've been learning I've been posting the tutorials. The link can be found in my signature. Hope it helps.

MikeD

iPhone Game Development Blog - 71Squared
Quote this message in a reply
Nibbie
Posts: 4
Joined: 2009.07
Post: #14
MR_UNOwen Wrote:Good news... I'm starting to figure things out. That sample code is paying off. LOL Wink Rasp Rolleyes Grin

Anyway... now I got a bunch of conceptual questions...

So the sample code I was looking at was this.

1) So... looking at EAGLView.m is this what happens: load the image/ get the attributes/ draw it to the buffer/ each time the timer goes off, clear the screen, rotate what's in the buffer and draw to screen?

2) I noticed there's a frame and render buffer. I understand the basic concept of buffer, but what does each do in contrast to the other in this case?

3) What's a texture in terms of OpenGL?

There's a bunch of other questions I have, but I'm sure I can figure it out by myself.

warmi,

That's really cool, I may use that engine in the future. Love

Honestly, you might be better off using Cocos2d. It has alot of what you're going to be building yourself. You can do a lot of manipulation (scale, animate, opacity, etc) of the images/sprices. Google it, cocos2d-iphone
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Getting started with my iPhone Game Jerm #1 6 2,798 Jan 20, 2010 10:43 AM
Last Post: KlassyGames
  Please help me get started. makinggames 5 2,989 Jun 20, 2009 09:54 PM
Last Post: Achithyn
  Getting Started Achithyn 4 3,050 May 13, 2009 01:27 PM
Last Post: Achithyn
  Where to go after "Getting Started"? XxtraLarGe 4 3,078 Oct 17, 2008 10:14 AM
Last Post: XxtraLarGe