What’s in Tutorial 10

Hi all

I’m currently working on code for Tutorial 10. This currently includes:

- Moving around a tile map
- Controlling the player using the accelerometer
- Colliding with the tile map (location the player cannot move through)
- Firing lasers
- Moving bad guys around

It could end up being a large tutorial which I may break into a couple of sessions. I am also planning on covering how to using your real device to provide accelerometer input into the simulator so you can test it on the Sim and not need to ALWAYS use the device when you want to test the accelerometer code.

There is no comparison with using a real device for your final testing, but not having to use a device to test that stuff is cool.

Colliding with things on the tile map can also be hard to get your head around. There have been some conversations on this on the blog, so I’ve decided to cover this off in the tutorial. I’m basically planning on showing how you can mark areas on a tilemap as solid and stop the player from being able to move through those locations, such as walls maybe.

I’d also be interested to hear about other things you would like to see in either Tutorial 10 or beyond :o)

Mike

Share:
  • Digg
  • del.icio.us
  • Facebook
  • MySpace
  • Reddit
  • StumbleUpon
  • Technorati
  • TwitThis
  • Design Float
  • DZone
  • email
  • Google Bookmarks
  • LinkedIn
  • Scoopeo
  • Tumblr

27 Comments

Mr Speaker  on June 13th, 2009

That sounds awesome – I’m very keen to see how best to manage baddies (of different types), weapons (of different types), and “collectibles”. The basics you’ve shown us are enough to make games now – but my spaghetti code for baddies and weapons is starting to get out of hand ;)

IPhoner  on June 13th, 2009

What about getting touches input, playing videos as intro and testing the compiled code on real device? ;)

Greg  on June 13th, 2009

I’d love to see something on just general collision detections. Especially if a “bullet” is traveling so fast that it “skips” over sprite due to the frame rate not being high enough. I guess this would also apply to detecting walls/floors if the character is moving so fast that it would “skip” over the wall or floor sprite.

Austin  on June 13th, 2009

If Tutorial 10 includes all this stuff I won’t mind how long it is. Really looking forward to this one! Thanks Mike!

mike  on June 13th, 2009

Thanks for the feedback guys.

I will certainly be covering touches and I’ll see what I can do covering things like collision detection for fast objects. This normally involves unlinking the logic of the game from the FPS, so that you can update the logic more frequently that the FPS which helps when tracking fast objects.

iPhoner. I’ll see what I can show about testing on a real iPhone, but that may have to be another tutorial as getting your device and the certificates you need from Apple etc can be a little involved. Its been made alot easier lately and Apple have some great info on it.

As for the baddies, I create a class per baddie type which is responsible for its logic and rendering, so I’ll cover that off.

Mike

Cubeur  on June 13th, 2009

Thanks a lot for your tutorials :)
I will try to modify your source because it woould be nice (to my mind) to have only one image with all the sprites (with differents sizes) because optimisation on pgn colors palette is better with one image (imho).

Thanks again

penguins  on June 14th, 2009

Can’t wait. Collision is going to be fun :p

Eskema  on June 14th, 2009

Mike, one question that makes me mad, you try your maps with a 60×60 or more map with 16×16 tiles, scrolling in the four directions?
Because I’m giving only around 25-30fps drawing a map with 2 layers, so I’m doing something bad with your code, or you have the same performance problem

mike  on June 14th, 2009

@Eskema, I saw your posts on iDevGames as well with this problem. It sounds odd as I’ve not seen any performance problems like those you are seeing. I’ve had a tilemap being moved using the accelerometer in all directions. The tile layer had 10,000 tiles and it was running at between 55-60fps.

Without seeing your code its hard to work out what the problem could be, but I am working on code for Tutorial 10 which will move a tilemap in all directions with the accelerometer which when done you could look at to see what could be different.

If there is anything you want to send me to look at just drop it to mike@71squared.co.uk

Mike

Eskema  on June 14th, 2009

The most important problem, is not my poor code (of course it is xD), I’m using your source, and I replace the map you have for another made with my tilesheet image, and 60x60x16, and the results are the same as my code. 25fps 2 layers.
I’m start thinking that the problem could be the tilesheet image, it has around 400 tiles, size 512×256.
I really appreciated your time, but I dont wanna bother you with my code, you have other business more important than loosing your time on my problems ;)

mike  on June 14th, 2009

Hi Eskema, no problem. I must admit that I have never used a tilesheet with that many tiles in before so that could be causing my code to run slowly. If this is a problem with my code I’d like to get to the bottom of it. Are you able to send me a map and tilesheet which is causing things to go slow. Anything you send would be deleted once I’d finished tracking down the problem :o)

Mike

Eskema  on June 14th, 2009

I dont have any problem to share my code, because its nothing unusual ;)
Ok I’ll zip your project and mine with the map and tilesheet I’m using to test, and send you, so you can see, the only change I made its the map and add the tilesheet, and move the position scroll, but who knows…

Arno  on June 15th, 2009

Hello,thanks for screencasts. I’ve try with 128×128 image for sprites in spritrssheet and result is not really what expected, it’s work with 64×64 96×96 but not 128×128 strange no ???

wuzutags  on June 15th, 2009

Hi mike, thanks for the tutorials. I’ve been following your tutorial for sometime which I find very useful. One thing I don’t understand you do is to always enable/disable gltexture_2d each time you draw an image. I think u could have done this once from the beginning, draw all images and disable it at the end. I’ve modified tutorial 6 to work this way and introduced a screen management system which really works well. I’d be grateful if you can add some basic pathfinding ai functionality to the enemies walking about. that will be cool.
Keep up the good work!

IPhoner  on June 15th, 2009

What about interuptions handling (Pausing the game and retrieving it again after incoming call or other interuptions such popup screen with “20% battery left” message?

Thank you.

mike  on June 15th, 2009

@iPhoner, that is something I’ll try and get into this tutorial. I will be covering things such having a main menu and doing simple transitions between that and the main game view, so I’ll also try and get a pause button in there as well etc :o)

Mike

mike  on June 15th, 2009

@Eskema, I’ve had a very quick look at your map etc. It does seem that having small tiles has an impact on performance. I’m running with a test map which has tiles that are 50×50 and a map which is 100×100. That is linked to the accelerometer and it runs really quick, over 50fps even with baddies moving around and particles.

When I do the same with a map that has 16×16 tiles then things do slow down. It looks to be more CPU bound that GPU bound, which could easily be down to the way that the Image class is working with the calculate texture coordinates as that is where it seems to be spending a lot of time.

I think it would be better if the texture coordinates were precalculated for a spritesheet and then just looked up, rather than calculated again and again. I’ll look into making this change as I’m sure it will have benefits. Apart from that, I’m not sure what else could be done without looking into the problem more, which I will do as I get time.

Hope that helps.

Mike

Eskema  on June 15th, 2009

Actually Mike, the main problem its not only the tilesize, as you said precalculate vertex and texture could be a great benefit, in fact could boost the game around 20fps easilly. But glblend is taking all cpu time right now. If I disable glblend, things turn back to a more stable FPS, around 45-60 wich is great.
I need to do some more tests :)

mike  on June 16th, 2009

Hi Eskema, that is a really good point as blending is a big overhead. I think it would certainly be useful for blending to be disabled if the tile map does not need it which should speed things up.

I’ve not found a way of improving the performance of blending as it has to do what it has to do.

For Tutorial 10 I’m going to add an option to the rendering selector in the Tiled class which will allow you to switch blending on or off and I’m working on the pre-calculation of texture coordinates for sprite sheets.

Mike

Eskema  on June 16th, 2009

Excellent news Mike, the only way to improve the performance its the precalculation of all tiles. Blending does not offer a way to avoid this overhead, except disabling it. Really complex all this opengl stuff

Eskema  on June 16th, 2009

I forgot one more thing, try and change this line in the setup of opengl

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND_SRC);

by this one disabling blending, I gain some fps

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

mike  on June 16th, 2009

Hi Eskema. I’ve not tried changing the glTexEnvi parameters, but by being able to stop blending of the tilemap and caching the sprite sheet textures I’ve got my tile map scrolling using the accelerometer, sprites moving around and particles etc at a really steady 60fps :oD

All the changes I’ve made and my example code for this will be inside Tutorial 10.

Mike

ieattictacs  on June 17th, 2009

I have only seen Tutorial 1, so sorry if the information is irrelevent. I am reposting a comment made on Tutorial 1 to make sure it is heard, I will then catch up, and probably update what needs to be updated in another post.

“Hey there Mike, I love your tutorials. I hope you don’t stop, if I had money I’d donate… Well anyways thank you for being the only tutorial source (and a good one at that) for iPhone App Programming. I think you should set up a news letter to update us, but just when you release a new tutorial, not the other posts. Or those could be an option or something.

Also, a tip would be to get more detailed with what you write, tell us why you type what you type as you type it, how it works and why you need it to work with the rest of the code. I wouldn’t mind having a 10min. longer video for easier learning. If you do listen then thank you, very much. Keep up the excellent work.”

mike  on June 17th, 2009

Hi ieattictacs and thanks for the comments. I’m always happy to hear how the tutorials could be improved and I’ll certainly see what I can do in terms of explaining things in a little more detail :o)

Glad you enjoy the tutorials

Mike

Joey Davidson  on June 21st, 2009

Absolutely fantastic tutorials, Mike. I, just recently, began learning Objective-C so I can develop for the iPhone, and I must say that much of your explanations are, in fact, quite helpful. I still have troubles understanding the most basic of syntax (because Obj-C and C++ are very different), but I know quite a bit of what works and what does not. I am looking forward to this final tutorial. I have already developed a game in flash, and to tell you the truth, I am quite excited to see how you are going to code up yours.

Joey

mike  on June 21st, 2009

Thanks Joey, I’m glad the tutorials are useful. The syntax can be odd, which is what I found coming from a Java background, but you do get used to it.

I’m working on the code for Tutorial 10 at the moment and I will be posting a video update later today. This is not the tutorial, but will give everyone sight of what I’m working on and should be in the tutorial.

Mike

Paul  on June 29th, 2009

Great tutorials Mike, keep up the good work!

Leave a Comment