GP2X Jabber's Log-fire


SVG.. Okay, here's how it works:

1. You use an editor to design your graphics. Inkscape, for example, is an excellent editor for the job. (http://inkscape.org/)

2. This produces a text file which is a description of the graphics .. not bitmaps, but rather an organized 'language' for how to construct the image.

3. Objects in this file are described, you can give them names, and you can arrange the internal structure hierarchically however you like. Your engine has a 'dictionary' of objects it looks for, such as "player", "enemy", "success", "failure", etc. These words map directly to the ID's in your SVG file of the objects that are supposed to be displayed when the specific state you're animating is active. The engine itself is a state machine .. "player moving" -> 'find object "player", move it', "player dead" -> 'find object "playerdead", display it", etc.

4. Your game engine reads this SVG file, parsing it (libsvg/libsvg-cairo/libcairo) and produces a CAIRO (http://cairographics.org) render-list. This render-list is a faster, vector-based (2d graphics) instruction set for how to construct the graphics described through your SVG. This is done on start-up of your game engine.

5. Your engine state machine runs, sequencing through the states in the machine, based on input, enemy animation, etc.


The reason I'm interjecting this idea into this thread, is because you said you wanted to learn something. I am actively watching your progress on this with interest, and I'm not trying to hijack your progress, but give you an alternative way to look at the problem. I also have an interest in the idea of creating a "Game And Watch" engine, for which games can *easily* be created using just the Inkscape editor and a standardized dictionary of objects which the G&W engine itself can understand .. I think this would be a good project. Please do not take my advice as an attempt to be critical of your efforts; certainly, what you are learning is of interest to me in the context of designing a general-purpose engine which could accomplish the same goal ..

In the end, I'd like to see a G&W engine that can have new games added to it simply by putting .SVG files in a common directory .. get where I'm coming from?

If you make your bitmap of the game-screen available somewhere (paste it in this thread even), I will convert it to SVG and make a very simple example of what I'm talking about for you to see why I think this is worth the discussion ..
 
torpor posted on Sep 29 2006 at 10:33 AM said:
If you make your bitmap of the game-screen available somewhere (paste it in this thread even), I will convert it to SVG and make a very simple example of what I'm talking about for you to see why I think this is worth the discussion ..
Don't worry about hi-jacking my progress. I am sure no one will notice. It is good to have your input. I was kind of hoping for interesting suggestions like this one of yours.

I know it is not important in a piddling little game like this, but will there not be be a performance loss using vector graphics as opposed to bitmaps ?

The only bitmap of the game screen I have is not an actual screen shot but a mock up. I am guessing you mean the one showing all the objects displayed at once. Because the photo I used to steal the graphics from was slightly squiffy so is the positioning of the objects.

I will see if I can generate a bitmap from within the program for you. If that fails then I still have the mock up but it needs straightening up.
 
Last edited by a moderator:
The screen :
jabber.jpg
 
Mr.Jabberwocky posted on Sep 29 2006 at 09:58 PM said:
I know it is not important in a piddling little game like this, but will there not be be a performance loss using vector graphics as opposed to bitmaps ?

This is a valid concern - only its not a problem with my suggestion, because SVG is only used as input to the engine, which parses the file and creates a CAIRO render-list of the objects, which is what you render to bitmap .. and if things get too slow, then just pre-render the CAIRO render-list once, buffer the results, and away you go ..

My use of this technique so far (I'm writing a game engine for fun, but not G&W-related .. yet) demonstrates that this technique isn't so slow, actually ..

The only bitmap of the game screen I have is not an actual screen shot but a mock up. I am guessing you mean the one showing all the objects displayed at once. Because the photo I used to steal the graphics from was slightly squiffy so is the positioning of the objects.

Yes, a screenshot with all objects will do fine .. I see you've posted it now and I will take this over the weekend and use it to demo the technique ..
 
Last edited by a moderator:
YakumoFuji posted on Sep 25 2006 at 01:07 PM said:
I know with donkey kong i (orange) ......
I was rummaging through some junk looking for paperwork ( 'vital 'according to 'Big Brother Bureaucracy') that I have lost (as usual) and I happened upon a long forgotton treasure. A real orange, multi screen Donkey Kong - with battery cover and serial number 43457072. The silver name plate shows the inevitable surface hairline scratches but there is no major marking or damage.

Sod the paperwork. I headed straight out and purchased a couple of batteries and it only still works ! What a result !
 
Last edited by a moderator:
You know, it could be quite interesting if this evolves into a generic engine to be used in reimplementing all those cheap pocket LCD games... maybe something along the lines of using some screen images and masks along with a script to control the gameplay?
 
torpor posted on Oct 2 2006 at 10:37 AM said:
BradN posted on Oct 1 2006 at 08:26 PM said:
some screen images and masks
No: SVG!!! :rolleyes:
I understand SVG is pretty nice, but for 'noob' useablity, you might want to think to go to a very well known format. Everyone can draw up a BMP in mspaint (LCD G&W games don't have to look good ;-))
 
Last edited by a moderator:
the point of using SVG is that it gives a structure to the files .. if you only edit bitmaps, you have to then make a mask, then cut each sprite out, then position it properly, then tell the app where to put the bitmaps, and the masks too .. this is, by far, not a newbie-friendly procedure.

if you use SVG: no masks required, and the app doesn't *need* to know the position of things in order to make them display as needed. using SVG for this also pretty much guarantees WYSIWYG ..
 
You've still got to tell it where to position the graphics on the screen. You just trade one issue for another in this case. With a couple screen images (one with all elements 'off', another 'on') and some way of selecting masks for each element, it'd be really easy to make masks in photoshop/gimp, etc...

One way to do masks might be using an 8 bit .png with one color per mask, then you aren't stuck making 80 separate mask images.
 
Despite the the distraction of the rediscovered Donkey Kong I managed to take a look at the SDL sound mixing function.

I recorded the sounds from the emulator using Audacity and added them to the project. This has been complicated by the fact that my GP2X is a bit tempramental about sound - sometimes it boots up refusing to make any sound and other times it is fine.

Mix_PlayChannel is the SDL function I thought would be the appropriate function to play the sounds. But unfortunately it likes to play the sound when it is ready rather than when I ask it to. You can fiddle with one of the parameters which varies the delay before the sound plays. However I still cannot get it to play exactly when I want and there is a loss of sound quality the closer I get it to the desired timing.

Is there any SDL guru who could tell me if it is possible to get the sound to play when I want ?
 
Code:
	if (Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 1, 512))
	{
		printf("Error opening SDL_Mixer: %s\n", Mix_GetError ());
	}
	int Mix_AllocateChannels(16);
	Mix_Volume(-1, MIX_MAX_VOLUME);
	
  TingSound[0] = Mix_LoadWAV("sfx/ting1.wav");
  TingSound[1] = Mix_LoadWAV("sfx/ting2.wav");
  TingSound[2] = Mix_LoadWAV("sfx/ting3.wav");
  TingSound[3] = Mix_LoadWAV("sfx/ting4.wav");
  BreakSound = Mix_LoadWAV("sfx/break.wav");
  SoundVolume = MIX_MAX_VOLUME / 2;
  Mix_Volume(-1, SoundVolume);
Loading code

Code:
Mix_PlayChannel(-1, TingSound[rand() & 0x3], 0);
Playing code.

Code:
  Mix_FreeChunk(TingSound[0]);
  Mix_FreeChunk(TingSound[1]);
  Mix_FreeChunk(TingSound[2]);
  Mix_FreeChunk(TingSound[3]);
  Mix_FreeChunk(BreakSound);
  
  Mix_CloseAudio();
Closing down code.

This seems to work pretty fine for me. The "512" number is the buffer size, that's important for correct timing (I use single channel audio, 16bit, 44khz, 512 samples buffer)
 
Fast response !!!!! Thanks. I had not come across Mix_FreeChunk. I shall be giving this a go tonight and let you know how it goes.
 
BradN posted on Oct 2 2006 at 06:15 PM said:
You've still got to tell it where to position the graphics on the screen.


You do it with an editor, which saves the position in the SVG file, which gets automatically parsed and handled. Thats exactly the point.

I've got a basic SVG file constructed of the Fire bitmap, and am able to animate it just fine, quite simply .. spending a few hours today working out how to implement an 'engine' approach to the gameplay, and then I'll put it up for business ..
 
Last edited by a moderator:
torpor posted on Oct 3 2006 at 12:16 PM said:
You do it with an editor, which saves the position in the SVG file, which gets automatically parsed and handled. Thats exactly the point.

Ahh, I see. I always thought of SVG as kind of a WMF on steroids - I wasn't aware it had that sort of functionality. Yeah, it would definitely work well then.
 
Last edited by a moderator:
Well it may be that part of the sound problem was that I am a dickhead. By playing it at the right time it should now be a bit better - but I can't tell because to-day my GP2X is not playing any sound at all.

I have uploaded the current state of affairs to EvilDragon's magical archive.

There is no colour option yet, but it does give a respite every 100 points and clears any misses at 200 and 500 points. It also gets a little faster at 200 points.
 
Now that's really cool!

My wife has taken a look as I was playing and remembers it!
Seems one of her friends might have had this game, Liz had one with a gorilla in it (perhaps!).

Sadly I didn't get any sound, although I've only tested it the once.
Exiting seemed to hang my unit (after showing me 4 1/4 size images of the last thing I was doing)

Second time in I get sound (and a whole 27 points!) but it still showed me the 4 1/4 size images (with a purple background) when I exited (pressing start)

Congrats Mr. Jabberwocky, this looks like a great piece of work.

Edit: Spelling....
 
Back
Top