Interest in 2D game engine?


13 posts
by Flojer0 » Sun Jun 10, 2012 9:12 am
I'm curious to see if there is any interest out there for a 2D game engine/developing enviroment for the pi. From what I've seen perusing the forums there is some interest in 3D engines, or porting them, but not much more.

It would be neat to have something similar to GameMaker, possibly having python as a scripting language.

A lot of what I see in the various 3d engine forums is worries of making it run at all or run effectively but I'd imagine r-pi could do very will with 2D graphics. Possibly herald back to the days of isometric rpg's and platformers.

If I can find the time (Between day job and making another game in Unity) I would like to at least throw together a rudimentary engine and make a game or two on the pi myself . Even if the 3D side of things work out I would appreciate having a dedicated 2D engine to avoid some of the necessary hoops of shoe-horning a 3d engine into 2d.

Thoughts?
Posts: 31
Joined: Sun Jun 10, 2012 8:10 am
by Gibble » Sun Jun 10, 2012 5:10 pm
Might depend what language etc. Just wondering why not give PyGame a go ?
Posts: 56
Joined: Wed May 09, 2012 9:52 am
by cheery » Sun Jun 10, 2012 5:35 pm
If you have nice bindings then using OpenGLES for 2D isn't a game breaker. Though I think this has been solved unless you want performance. Give pygame a go.
User avatar
Posts: 219
Joined: Wed Jan 25, 2012 9:39 pm
by Flojer0 » Mon Jun 11, 2012 1:49 pm
I was going to give pygame a look, but c/c++ and access to the GPU could also give some worthwhile performance benefits.

So what I'll do is give myself a crash course through pygame while I wait for my pi (a little under a month now) and if pygame doesn't do what I want I'll be back with that basic game engine. Though if I'm the only one who cares I'll probably just put enough effort in for a better looking than pygame game. We'll see.
Posts: 31
Joined: Sun Jun 10, 2012 8:10 am
by kaplanfx » Fri Jun 15, 2012 11:01 pm
I wonder if the Pi needs its own specific 2D game engine? Using pyGame or something like cocos2d:http://cocos2d.org/ would probably be sufficient. I just saw this awesome article on 2D game programming here: http://higherorderfun.com/blog/2012/05/20/the-guide-to-implementing-2d-platformers/ I'm a mediocre programmer and a Python amateur so I'd have to start things off pretty slow.

-kap
Posts: 9
Joined: Fri Jun 15, 2012 10:56 pm
by cheery » Sat Jun 16, 2012 10:01 am
Pi doesn't need it's own specific anything in fact. Anything open source written to linux can be ported to pi.

Though lets acknowledge it's good target hardware for designing new things. You'll have better control of hardware compared to PC, despite the GPU blob.
User avatar
Posts: 219
Joined: Wed Jan 25, 2012 9:39 pm
by Braqoon » Sun Jun 24, 2012 12:27 am
I had my game running.
https://vimeo.com/43205057
This is a custom build 2D engine for my needs and game never seen raspi before. Python + Pygame is a great starting point for anyone.
http://dfourgames.com/
User avatar
Posts: 15
Joined: Sun Jun 24, 2012 12:17 am
Location: Sheffield, UK
by Flojer0 » Tue Jun 26, 2012 5:04 am
My pi should be here in a couple more weeks, just got notice of shipment.

I'll take a look at pygame first. If I find the time I'll get some tinkering done before it gets here to help my start. I really do want to contribute a game targeted specifically at the Raspberry Pi. I like what it is doing and feel that games really do help push out hardware.

If pygame doesn't give the performance I want I'll just jump to OpenGL ES. I've tinkered with OpenGL before and didn't find it hard to get 2d graphics going, so I wouldn't be too far out of my league.

@Kaplanfx: neat article on 2d implementation. I was thinking of sticking to a fairly basic original Mario brothers style of gameplay, but with some of the things that article talks about I might beef it up a bit.

@Braqoon: Where do you think the performance hang up is in your game? Could it be in your code of is that the python and pygame? If it's the latter I think I'll switch to some hand built opengl before I even get my Pi!
Posts: 31
Joined: Sun Jun 10, 2012 8:10 am
by Braqoon » Tue Jun 26, 2012 2:32 pm
@Braqoon: Where do you think the performance hang up is in your game? Could it be in your code of is that the python and pygame? If it's the latter I think I'll switch to some hand built opengl before I even get my Pi!


I haven looked properly into it yet, but i think bulk part will be image processing as pygame loads png to memory uncompressed afaik. Add to it transparent layer of png and that's even more. I got some large pngs to load which any normal computer will laugh but with limited memory and processing power this can be an issue.

Optimizing graphic files, reducing max resolution (currently game got full HD support) should give a big boost to the performance. As for a code i think there will be a space for improvement but this is not my area of expertise so i only assume. I have build a game to resize on the fly and be quite flexible so making adjustments to some constant spec will improve performance as well.

Lastly Os is to blame as well. Memory is a luxury in raspi so anything counts. IMO preferred Debian is not optimized well and simple tweaks can boost overall performance.
http://dfourgames.com/
User avatar
Posts: 15
Joined: Sun Jun 24, 2012 12:17 am
Location: Sheffield, UK
by cheery » Tue Jun 26, 2012 3:19 pm
I've written some python code for this, that shouldn't be too hard to understand: viewtopic.php?f=38&t=9389

It does some erratic things at raspberry pi, but otherwise works and could be a good starting point for an efficient 2D game engine. Although I'd first fix the problem in passing arrays to C-functions.
User avatar
Posts: 219
Joined: Wed Jan 25, 2012 9:39 pm
by Flojer0 » Mon Jul 02, 2012 6:11 am
Alright, this last week my pi finally came in. I've been spending time acclimating to it. The cpu does leave a lot to be desired and ram can be scarce when I'm absent minded. I think I froze the thing stuffing the ram full of web pages a couple of times already.

Now I need to finish up my crash course through python/pygame and see if I could puke something useful out. possibly a basic benchmark to see how many sprites the thing can blit and maintain a good frame rate.

I did learn that I'll most likely be developing on my primary machine and testing on the pi, Arch Linux performs pretty well but it will still be a better use of my time to build the game on a faster machine.

It also appears that I'll come to appreciate past experience with c/c++, may become priceless when performing optimizations.

lastly, I hear pygame is suppose to use hardware acceleration for graphics if it's available. is there any word on if there are gains to be found dropping into opengl yourself vs. using pygame? I can see myself appreciating the time saved not having the dive to deep into opengl if I can mange though.
Posts: 31
Joined: Sun Jun 10, 2012 8:10 am
by cheery » Mon Jul 02, 2012 8:17 am
Pygame seems to be un-accelerated. But if you get into opengl, you have to understand texture atlasing and shaders at least.

I could help you out if you drop at freenode.net #raspberrypi
User avatar
Posts: 219
Joined: Wed Jan 25, 2012 9:39 pm
by terrymisu » Tue Apr 16, 2013 2:29 am
Pygame uses OpenGL for hardware rendering if available, but the Raspberry Pi uses OpenGL ES. From what I've been able to deduce it's not hardware accelerated. I don't think the glue exists for pygame to hook into OpenGL ES.

I'm currently trying to get the Spine 2D skeletal animation runtime (esotericsoftware.com) running on the Pi.

I've ported Spine to Python using pygame (spine-python, pyguts), but I can only eke out about 5.5 frames per second using full screen mode on the Pi doing dirty rectangle updates. I only get about 4.5 frames per second if I do full screen redraws.

This is nowhere near fast enough to do what Spine needs, so I'm looking into other options. I got pogles running on my Pi last night, but I haven't done anything OpenGL related in ages, so I don't have a good way to benchmark it (does anyone have any good OpenGL ES benchmarking tools?).

Ideally I'd like to use a 2D gamekit that can render fast and has APIs for rotation, blitting, etc... so I don't have to reinvent the wheel, but I'll do it myself if the alternative proves to be too painful.

Oh, and getting pogles running was a bit of a pain - if anyone wants the instructions let me know.
Posts: 2
Joined: Tue Apr 16, 2013 2:23 am