- First up, a new sound class. Sound was giving a lot of trouble.
- Next, a better long press implementation.
- I've been giving consideration to the concept of never displaying a background bigger that the original, to avoid jpg artefacts.
Friday, 31 August 2012
I'm horrified...
Saturday, 28 July 2012
A Hesitation
I still have to sort out Music/Sound Effects. I'm also uncomfortable with the feel of long press as I've implemented it, so I'll have another go at that when I return.
Monday, 23 July 2012
Music Design Unsuccessful
I note a lot of such mysterious problems on Stackoverflow, and I may change policy here.
Also, I think it should have been a class rather than a method, and I'll re-write it like that. I may also have to use the MediaPlayer for longer music and the Soundpool just for immediate sound effects. We'll see. MediaPlayer is facility-rich, but seems rather complex to use.
Wednesday, 18 July 2012
Music Design Revised
Friday, 13 July 2012
Some Progress and a Design for Music and SFX
I realised I hadn't accounted for save and restore of holdable items. If it's already held, then all we need remember is the sprite that's being held. This can be achieved at the top level, where the player's current location is remembered. If, however, the sprite has been picked up and dropped away from its home screen, then the scene and x y have to be remembered. Code to do this is in test.
Design for Music and SFX:
It's currently my plan to use the SoundPool facility. This allows you to store a number of sound files with the application and also allows several channels to play at once. In this case, I would use one channel for the theme music or soundscape (e.g. birdsong, waves, wind etc.) of each scene, and another two for individual sound effects.
I think I can put this in a thread, which first loads the sounds, then is wakened up every 200 ms, say, which checks a variable in JadeView for each of the sound channels. Once it has started the channel, it sets the variable to "done". It can then see the next sound request when "done" is replaced. If the soundscape is unaltered, it just continues to play.
Tuesday, 10 July 2012
More on Cursors and Pick up & Drop





I implemented Pick up & Drop using (as recommended by Android Developers) Long Press, rather than Double Click, which I had planned. So far, the Long Press seems too short at 384ms. It will be tuned.
I went for the complicated option - a gettable sprite that is also animated and scaled. That bit works fine
Monday, 2 July 2012
Cursor Implemented
- Default - blank
- The four direction pointers
- The crosshairs
- The Hand - indicating something that can be operated or picked up.
- Picking up and dropping items
- Music and sounds. Probably using SoundPool.
- Putting a Beta version together
Thursday, 28 June 2012
Useful Stage Reached
Quit : finishes the game
Music On/Off : tweaks the music flag, though no music is currently implemented
Inventory: enters the Inventory scene (which cannot be saved)
User Save/Restore : uses 4 possible local files to save/restore any position
also:
Android Save/Restore : to deal with situations where Android OS does something outside the game's control - e.g. Change orientation; Pull a different Activity into foreground; Destroy game for lack of resources.
In this case, the game saves its current position with the Android's own memory of the game, and restores it when the game is restarted.
All tested on both the PC-based emulator and on a Xoom device.
Thursday, 21 June 2012
Save and Restore
Next task is doing the user save / restore options. Then I'll implement the QUIT function.
Thursday, 14 June 2012
Tuesday, 12 June 2012
Scale, Flip and Mirror on Sprites
The following snatch of code takes image im and transforms it to scaledbitmap.
scale (x and y values) are based on 100 as full size.
flip x and y values are either 1 or -1.
1,1 means as original bitmap
-1, 1 means mirrored in the y axis
1, -1 means flipped on the x-axis
-1, -1 means mirrored on both axes - i.e. inverted
// scale image before return
Matrix matrix = new Matrix();
// scale and flip
matrix.postScale((float)flip.x*scale.x/100, (float)flip.y*scale.y/100);
// create a new bitmap from the original using the matrix to transform the result
Bitmap scaledbitmap = Bitmap.createBitmap(im , 0, 0,
im.getWidth(), im.getHeight(), matrix, true);
return scaledbitmap;
Monday, 11 June 2012
The GUI
Having further considered the matter of the GUI, I've decided to base it all on sprites, rather than a special screen. It is probably neater, and certainly more efficient. So another carefully designed backdrop hits the wastebin.So, what's still to do?
- Scale, flip and mirror on sprites;
- Cursor;
- More detailed touch control;
- Pick-up and drop;
- The save / restore for Android OS operations. The game has to be revivable if it is re-oriented, de-focussed etc. by the user. It's an Android preoccupation;
- Similarly, and, I hope, using the same compression technology, the user save / restore;
- Music,which I hope to implement by using the built-in MP3 player;
- The Jade game itself, for which I have a lot of scenery and virtually no plot;
- The various delivery activities to get it to Beta Test and Android Market.
Saturday, 9 June 2012
Progress to Date
- Scaling for whatever size of playfield is available works perfectly.
- After pestering with invalidateRect() for weeks to deal with the "dirty" rectangles on the screen, and finding it doesn't work the way I expected, I now just repaint the whole playfield (the image part of the View) every tick. In tests, both on emulator and Xoom, it's fast enough, even with a couple of active sprites. My ticks are approximately 18/second;
- I can detect a touch in various aspects;
- I can click a sprite and change screen, I've dealt with the problem of re-entrant popscreens;
- I'm wrestling with the GUI concept. Basically, there's an icon on every screen, which, if clicked, takes you to an options screen where you can choose to select the inventory screen, quit, save, restore or switch the music on and off (the music is not yet incorporated);
- I can display moving sprites (the gulls in the illustration below) with multiple (24, in this case) images.
Tuesday, 29 May 2012
Scaling and Displacement
With the multi-platform Android version, any given game background size need not be based on 640 x 480, but may take any rectangular size. In addition, the eventual playfields can be many sizes and usually will not not start at position 0, 0. Sprites will be scaled and their position on the screen scaled appropriately. Touch positions will be similarly displaced.
All collisions, zone effects, sprite movements and other screen events will be computed in the program on a game model which is at the basic background dimensions.
So, for drawing and detection of user touch, all positions, including background, sprite positions, dirty rectangle positions and touch positions, we have to make a transformation.
Rule 1. All images are pre-transformed to the correct scale. (This to save processing time during animation)
Rule 2. All position calculations are initially made on the base dimensions of the background playfield and proportionate sprite positions, and are only resized and displaced at draw time.
Rule 3 All touch co-ordinates are similarly transformed to base positions (by rescaling in reverse and subtracting the displacement) before being applied to the base model.
For example, the background. In any given scene, the background image does not vary. It is efficient to scale the image at the outset of the scene. Once scaled, and its displacement from position 0,0 determined, it can be drawn, in whole or in part, without having to scale the bitmap every time.
Similarly, sprite images will be resized, but all dimensions and positions will be reported to the base game model on the (in this case) 640x480 basis.
The actual placement and size of the sprite will be deternined in the draw stage.
There is a slight complication. Sprites can be scaled, flipped and mirrored , and this is done prior to the general scaling transformation.
It's not really so complex. Is it?
Sunday, 20 May 2012
A Little More Progress
Just mopping up some of the display manager functions, and checking out thread behaviour for the timer.
Saturday, 19 May 2012
More Struggle
Anyway, I've made a little progress with the game but I don't want to go too far without testing my changes on the emulator which I can't do right now.
re. Bundle management
For simplicity, it's best if the game restore string for orientation is the same structure as the optional game save file that's stored locally.
Therefore, I am not going to make use of the Key:value pair structure in the Bundle except to label the whole save string.
In addition, since the game may be updated/altered, the save string must always be forwards/backwards compatible.
Must watch out for possible duplicate keywords e.g. spritename/scenename both called "pause"; imagenames will often be the same as sprite/scene names. Partially identical names in the savestring could also be problem, as we search it for spritenames among other things. Perhaps all keywords in the string should be uppercase and preceded by a type letter. e.g. S for sprite, R for scene(room), G for general state markers.
re. Scene alteration
Mostly, changed or additional zones with new destinations. Occasionally, delete zone. Sometimes, different image(s) or music.
So, for any alteration - like an open door with a new exit, we just have a key in the save string that causes us, on restore, to call a method in JadeData which makes the alteration.
Thursday, 3 May 2012
Unecessary Struggle
Wednesday, 25 April 2012
A Few More Topics
- Background transitions: It should be easy to slide one background over another, one doDraw() at a time.
- Sprite scale, flip and mirror: Must do some experiments with this, but it looks as if a single bitmapFactory call with a suitable matrix could do the whole modification on a Sprite image.
- onPause and onResume: A save string could be attached to the Bundle, just to restore the current state. The deliberate saves (by User) would use the same save string format, but stored in a local file.
- Lighting the Rocket: A candle in a cave.
Monday, 23 April 2012
More Design
There will also be a need for cutting off a portion of any sprite that strays across the background boundary.
Both of these can be handled in the doDraw portion of the code.
--------------------------
Some scenes will be labelled "no popscene", eg Inventory, save, limbo.
---------------------------
Design suggestion: So that we don't need to use text to label the various saves, icons of jade Chinese horoscope characters (eg dragon, tiger, ox, monkey) will be used.
Sunday, 22 April 2012
Quick Design Points
Sprite images will be collected full size. On scale change in the sprite, they will be re-scaled in the sprite's image list.
Decision 2:
View scaling will be done at doDraw time. After all, it's only one rescale per sprite.






