tag:blogger.com,1999:blog-64190694264089174882024-03-19T04:20:36.877+00:00Amazon SystemsDocumenting and sharing this Myst-like Adventure creation system.Gilhttp://www.blogger.com/profile/08021058996570815548noreply@blogger.comBlogger113125tag:blogger.com,1999:blog-6419069426408917488.post-78635319515261981992015-04-13T09:49:00.000+01:002015-04-13T09:49:51.798+01:00Another Aide-Memoire PostNow Spring is here, I find any free time gets gobbled up by gardening, repairs, golf and other chores. The trouble is that, though programming progresses steadily, images take lots of time.<br />
<br />
However, there is an upside to tedious activities, namely that I can think about Jade while I'm doing them. Unfortunately, many of my most brilliant thoughts tend to vanish before I get time to implement, or even record them. So, I've taken to scribbling these gems of wisdom on any convenient sheet of paper or cardboard, and I'm getting them down in writing before they get rained upon.<br />
<br />
Additional images required:<br />
<br />
Junk:<br />
<ul>
<li>Stationary - no sails, Animated - raise sails - May be the same view from junkhie</li>
<li>Moving off - May be the same animation varied only by size</li>
<li>Seen from sea level </li>
</ul>
Rocket (from junkhie):<br />
<ul>
<li>Lift off</li>
<li>Graceful parabola </li>
</ul>
Furniture:<br />
<ul>
<li>More furniture for views from junk (distant junks, gulls, already provided). Perhaps purloin scenes from the Povray library</li>
<li>A few oddments for the interior/deck of junk </li>
<li>Arrows on pylons (no need for binoculars in close-ups - use a single background and bounce)</li>
</ul>
<br />
<br />Gilhttp://www.blogger.com/profile/08021058996570815548noreply@blogger.com0tag:blogger.com,1999:blog-6419069426408917488.post-62700223087394517712015-04-06T11:39:00.000+01:002015-04-08T10:26:15.518+01:00New UploadsI've uploaded the latest versions of the game (jade.apk) and the Java source (jade.zip) to<b> <a href="http://amazonsystems.phpzilla.net/" target="_blank">the code repository for the project</a></b><br />
<br />
Let me have any feedback on the game you care to send me.<br />
<br />
Some of the style of the Java code is, I confess, rather untidy. It's been through quite a number of different generations of compilers and build engines since its first origination in 1993, and I'm tidying it up as I go along.<br />
<br />
Android Studio: <b>Don't do it this way, do it that way</b>.<br />
Me: <b>Oh, get a grip. It works, doesn't it?</b><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgiN3z_6tbiZvgdZwmhx92g8iW0ZZgqwQveZYunTkoUQsEgoNOmWr2EAr2b6SDQFZzVD56tgHQkzvTahneVOWrVdcH9N3xf51r-mauCWTat889z8Gz6uputw08gVVFvq2GrvMLBYy1XxEyy/s1600/Pylon.bmp" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgiN3z_6tbiZvgdZwmhx92g8iW0ZZgqwQveZYunTkoUQsEgoNOmWr2EAr2b6SDQFZzVD56tgHQkzvTahneVOWrVdcH9N3xf51r-mauCWTat889z8Gz6uputw08gVVFvq2GrvMLBYy1XxEyy/s1600/Pylon.bmp" height="240" width="320" /></a></div>
<br />Gilhttp://www.blogger.com/profile/08021058996570815548noreply@blogger.com0tag:blogger.com,1999:blog-6419069426408917488.post-49437051847035271822015-02-22T10:41:00.000+00:002015-02-22T18:24:12.235+00:00Timing of the LoopThe animation problem represented by the rocket (mentioned in the previous post) led me to start tinkering with the Ticktimer() thread. In particular, the amount of sleep() I give it. Allowing the timer less sleep (reducing from 80ms to 16ms) gave the animation a superb boost, and the jerky animation disappeared altogether. Of course, the emulator with debug (on PC with Android Studio) still moves pretty slowly, but running on a naked Android device is highly efficient.<br />
<br />
Pretty soon, I'll have to implement a "disable touch response" system, so that the user can't do anything during an animation that has to run to completion.Gilhttp://www.blogger.com/profile/08021058996570815548noreply@blogger.com0tag:blogger.com,1999:blog-6419069426408917488.post-76920457059786197942015-02-19T14:16:00.002+00:002015-02-22T10:00:24.128+00:00Using a Rocket Built a set of images for a runaway firework, but it didn't work so good, not because the images were wrong, but because the animation was extremely staccato and jerky.<br />
<br />
Back to the drawing board...<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh309FjQpf6vkiP6jSPv-Y-Yffk92kdyUs2ZiAcdzUkeMs1tjG_v-kxEo-7kJPz2wzMZfAMs1IOk-X9uF0z0OU8dIWuK6eDF-EZeNf2rHs9aFDz3kdmUphwF_WjZdKa0RhXEXDnpuXsxs0b/s1600/Image13.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh309FjQpf6vkiP6jSPv-Y-Yffk92kdyUs2ZiAcdzUkeMs1tjG_v-kxEo-7kJPz2wzMZfAMs1IOk-X9uF0z0OU8dIWuK6eDF-EZeNf2rHs9aFDz3kdmUphwF_WjZdKa0RhXEXDnpuXsxs0b/s1600/Image13.jpg" /></a></div>
<br />Gilhttp://www.blogger.com/profile/08021058996570815548noreply@blogger.com0tag:blogger.com,1999:blog-6419069426408917488.post-61662994955583087912015-02-14T11:27:00.002+00:002015-02-14T11:28:00.518+00:00Multiple Sprite InteractionFound, and solved, a number of problems associated with swapping a pair of sprites as a result of interaction with a third. It was all to do with the sequence in which events took place, and was surprisingly complex. Now, it looks like a piece of cake, but it took me a whole day and some rearrangement of basic code to accomplish. Still, a nice challenge.Gilhttp://www.blogger.com/profile/08021058996570815548noreply@blogger.com0tag:blogger.com,1999:blog-6419069426408917488.post-76783555379363090802015-02-09T18:07:00.003+00:002015-02-10T12:26:15.047+00:00Problems with Conditions that Affect Multiple SpritesCame across a problem today, concerning, really, the behaviour of one sprite dependent on another. This isn't something that can be resolved in the sprite's code, because no sprite is conscious of another sprite's existence i.e. it can't access another sprite's context. All such arbitration has to take place in the module that instantiated the two sprites.<br />
<br />
The particular case is when the rocket launcher already has a rocket in it, and the user tries to put a second rocket in the launcher.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrwiMLxUooA-3U8GGxuQZa6AmSCYL01onq1ahG7EZBq4WeDJRTHlWCzQgZHiDTpvlpVPVUj2M75ZNfPydwVnD8YyKxVE6M_0qrAJCsvmUZli7BcboV5PzqyMEFus7-3vLAtGAtKRj2jAs3/s1600/acavein.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrwiMLxUooA-3U8GGxuQZa6AmSCYL01onq1ahG7EZBq4WeDJRTHlWCzQgZHiDTpvlpVPVUj2M75ZNfPydwVnD8YyKxVE6M_0qrAJCsvmUZli7BcboV5PzqyMEFus7-3vLAtGAtKRj2jAs3/s1600/acavein.jpg" height="240" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
Later: The state of background sound off is not preserved over a Save Restore.<br />
<br />
Later still: A new test version of Jade is available via the link in the left hand column.Gilhttp://www.blogger.com/profile/08021058996570815548noreply@blogger.com0tag:blogger.com,1999:blog-6419069426408917488.post-45465823802938818632015-02-09T00:53:00.001+00:002015-02-09T17:57:48.598+00:00Furniture SpritesStarted implementing Furniture sprites, discovering, incidentally, that if a sprite's image cannot be found, Jade crashes. Must fix that.<br />
<br />
Though Furniture sprites are INACTIVE (i.e. don't react to touch or collision), they sometimes have to be moved to and from Limbo, so their 'home' scene and location are remembered. Initially, I set up special variables to remember these, but it occurs to me that I could use a single Dropzone for the purpose. Saves coding.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEbP5Va78x4Z1eFXTQoBKyLzbtcGwqlBZOd1KL8FCvno4ssmcP4gbDw-_UUOK4Xz1BA6j-p5HfffjyQrsuF6gNQ1s2mb4MAZy9_slI2a89SBqSEGZuELhYZ5W8kDRtQX5tKS5jAeStT9aT/s1600/junk205.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEbP5Va78x4Z1eFXTQoBKyLzbtcGwqlBZOd1KL8FCvno4ssmcP4gbDw-_UUOK4Xz1BA6j-p5HfffjyQrsuF6gNQ1s2mb4MAZy9_slI2a89SBqSEGZuELhYZ5W8kDRtQX5tKS5jAeStT9aT/s1600/junk205.jpg" height="240" width="320" /></a></div>
<br />Gilhttp://www.blogger.com/profile/08021058996570815548noreply@blogger.com0tag:blogger.com,1999:blog-6419069426408917488.post-62988250432754606522015-02-07T01:02:00.001+00:002015-02-07T01:02:25.654+00:00Rocket spritesBuilt and tested the carryable rockets. Also need the 'dummy' rockets in the distant view. These will be 'furniture' sprites.<br />
After long contemplation, decided that the furniture sprites, though they tend to be static, should also be MOVABLE, so they can be shoved into Limbo, as will happen with the dummy rockets. So probably <i>type</i> is an irrelevant attribute of Sprite, but I'll leave it there for the time being. The other attribute - GETTABLE, however, is significant, as is ACTIVE.Gilhttp://www.blogger.com/profile/08021058996570815548noreply@blogger.com0tag:blogger.com,1999:blog-6419069426408917488.post-26419127196244476912015-02-05T11:20:00.000+00:002015-02-05T11:26:52.776+00:00Re: Switches, Conditional Scenes and Use of Inventory<b>Switches:</b><br />
<br />
I had thought I might have to implement a new class - Switches - to enable recognition of new conditions (e.g. Rocket already fired) and to give a handle to Save and Restart. However, I am now sure that Sprites themselves will be sufficient, either by detecting the the presence or position of a Sprite, or by creating a Zombie Sprite whose Position data can be used to indicate a state. The Zombie would be saved and restored like a carryable or movable Sprite. The Zombies would be in the Limbo scene (which is unreachable by players), and would never need to be drawn in real play, though inspection by developers of the Limbo scene would aid debugging..<br />
<br />
<b>Conditional Scenes:</b><br />
<br />
I have now implemented a function in JadeData that inspects every destination scene before a scene switch, and changes the destination scene according to current game conditions.<br />
<br />
<b>Use of Inventory</b><br />
<br />
Hitherto, if a carried sprite was dropped, and there was no specific dropzone on that scene, it was dropped into Inventory. I'm changing this so that Inventory drops only occur if there's a specific location in Inventory specified in the sprite dropzones. Otherwise, no drop will take place.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMarDI03lUlNKBoLWWI2vifuKi6Zdg8R9wG4dCgKP60DbNEcaL7HT-Q4rroscHF_6mbS_nRpbCMaEhiDIbcYP1zWIY8L-lnKX0ZQ9zL8j3jazj4jJjlmEJDXZHrVIiak9KeGhjHF6pmNXf/s1600/incavew.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMarDI03lUlNKBoLWWI2vifuKi6Zdg8R9wG4dCgKP60DbNEcaL7HT-Q4rroscHF_6mbS_nRpbCMaEhiDIbcYP1zWIY8L-lnKX0ZQ9zL8j3jazj4jJjlmEJDXZHrVIiak9KeGhjHF6pmNXf/s1600/incavew.jpg" height="240" width="320" /></a></div>
<br />Gilhttp://www.blogger.com/profile/08021058996570815548noreply@blogger.com0tag:blogger.com,1999:blog-6419069426408917488.post-4223687154872224482015-01-25T00:26:00.000+00:002015-02-05T10:58:17.308+00:00ProgressCreated a bunch of new scenes, all to do with the subterranean caves.<br />
<br />
Now need to design the code to allow change of Exit as a result of user action. For example, if the candle is present, the cave backgrounds are illuminated, so the destination screen might be different. Or to have the junk present. Also necessary to record the change so that a runtime save / restore can recreate the changes.<br />
<br />
<br />Gilhttp://www.blogger.com/profile/08021058996570815548noreply@blogger.com0tag:blogger.com,1999:blog-6419069426408917488.post-1172052971638244062015-01-21T01:42:00.000+00:002015-01-25T00:31:10.000+00:00At the End of Another Long GapSince my last post - more than a year ago - matters have been largely stationary, due to an extended project with no connection to this, but which tied me up, with barely the time to do my Mythaxis business.<br />
<br />
You haven't missed much. I made some performance improvements, added a cursor which follows the touch and stays where the last touch lifted. The major change happened after a painful time with Eclipse, on upgrading desktop hardware, then wifi problems, only finally resolved last week when when I migrated the project to Android Studio.<br />
<br />
For a while last year, I was unable to work on povray because of remote accessibility, which I needed.
So, I've moved onto the rocket cave in povray, and will be extending the game and the engine real soon now.
Gilhttp://www.blogger.com/profile/08021058996570815548noreply@blogger.com0tag:blogger.com,1999:blog-6419069426408917488.post-29461443550876136172013-12-05T02:20:00.001+00:002015-01-25T00:32:11.652+00:00Bug FixSmoothed out the size fitting algorithm, with the result of much cleaner renders.<br />
Fixed a bug whereby if a sprite was dropped on a page with no valid position so that it went to the inventory in the position of the inventory exit, then it couldn't be picked up!Gilhttp://www.blogger.com/profile/08021058996570815548noreply@blogger.com0tag:blogger.com,1999:blog-6419069426408917488.post-24019693942575995482013-12-04T01:22:00.001+00:002015-01-25T00:33:15.311+00:00Incredible time gap...... but I'm back at my little forge, carving this and that.<br />
I built another test version which you can load from <a href="http://amazonsystems.phpzilla.net/"><b>this handy link</b></a>.<br />
I was dissatisfied with the re-rendering engine in android java, so I built a version that only does a few sizes of playfield. It needs work, but it's viable.<br />
Gilhttp://www.blogger.com/profile/08021058996570815548noreply@blogger.com0tag:blogger.com,1999:blog-6419069426408917488.post-2699023165877047732013-04-09T14:38:00.001+01:002013-04-09T14:38:57.407+01:00Another Aide Memoire postI have so many scribbled bits of paper that I keep losing. I'm going to do a list of the scenes with scene numbers and names.<P />
<UL>
<LI>200 Hi N (junkhin) (with rocket launcher)
<LI>201 Hi S (junkhis) (above beach)
<LI>202 Hi W (junkhiw) (towards rocks)
<LI>203 Hi E (junkhie) (to distant sea)
<LI>204 Unlikely to use
<LI>205 Unlikely to use
<LI>206 Lo N Parked junk (junklopark)
<LI>207 Unlikely to use
<LI>208 Lo SW beach Probably won't use it
<LI>209 View back up cliff (junkloup) Cliff path painted in.
<LI>210 Lo South beach (junklosb) Landing place on lo level.
<LI>211 No use at present
<LI>212 High, looking down on beach but beach has to be painted in (junkhisx)
<LI>213 Lo N no junk (junklon)
<LI>214 Lo W (junklow)
<LI>215 Lo E Dark cave (junkloe)
</UL>
That's all for the time being. I'm building another prototype.Gilhttp://www.blogger.com/profile/08021058996570815548noreply@blogger.com0tag:blogger.com,1999:blog-6419069426408917488.post-41684347888199567162013-04-04T00:30:00.000+01:002013-04-04T00:30:36.723+01:00Catch-upWhat time I've spent on the project since November has been spent on Povray, which doesn't lend itself to blogging. But Christmas, another issue of Mythaxis, and a bit of home improvement took priority at various times. We now have a couple of animated junks, an advance on Rock design, and a cave.<p>
On Jade code, plans are afoot to distinguish between animated and static images for the same sprite. Also, it's now clearer how to restore configurations which are changed as a result of user action. e.g. where zone destinations have been altered, or resources used up, or doors opened.Gilhttp://www.blogger.com/profile/08021058996570815548noreply@blogger.com0tag:blogger.com,1999:blog-6419069426408917488.post-88543386402318712422012-11-12T13:00:00.001+00:002012-11-12T13:00:40.421+00:00Ignore this entry - I'm talking to myself.Things to resolve:
<P>
<UL>
<LI>How to dispense rockets one by one only.
<LI>Caves. Probably start again with new .pov file.
<LI>Candle Illumination - cave dark without candle or with candle in inventory.
<LI>Mirror the junkani pictures for speed.
<LI>Stationary / moving junk - triggered by rocket.
<LI>Rocket ignition without tube - explosion.
</ul>
<P>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYjcEiMU0rblZr3j8EoxV9KJd4dp7LjmvBc3z5GAsZR6rlBa8c70e1x-p4hczzCAvuYV1bUOO-lckojxNsMIkeqzPCDVxQbT8A81hvL63PNHr2DEhCIxeBBFUs1uwHQCjtuREF0DJj-AZn/s1600/junkani.gif" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="80" width="89" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYjcEiMU0rblZr3j8EoxV9KJd4dp7LjmvBc3z5GAsZR6rlBa8c70e1x-p4hczzCAvuYV1bUOO-lckojxNsMIkeqzPCDVxQbT8A81hvL63PNHr2DEhCIxeBBFUs1uwHQCjtuREF0DJj-AZn/s400/junkani.gif" /></a></div>
Gilhttp://www.blogger.com/profile/08021058996570815548noreply@blogger.com0tag:blogger.com,1999:blog-6419069426408917488.post-32331127891731274632012-11-04T00:38:00.000+00:002012-11-04T00:38:21.244+00:00Composite Sprites (contd.)Oh, and I might well have persevered with composite sprites had I not encountered the SAVE / RESTORE implications.Gilhttp://www.blogger.com/profile/08021058996570815548noreply@blogger.com0tag:blogger.com,1999:blog-6419069426408917488.post-26909098126370382342012-10-30T18:23:00.000+00:002012-10-30T18:23:08.366+00:00Composite SpritesI was planning a new Class - a composite sprite - which would enable a number of sprites to be considered as a cluster which always moved together, but might have different schedules - e.g. a static main sprite, such as a boat, with animated bow wave, only when moving, and an animated flag which might wave or droop.
<P>
My first draft of this class quickly showed me the error of my ways, as the coordination of the multiple sub-sprites would be extremely difficult, due to scaling and flipping, for example. Especially scaling.
<P>
Unless.. the multiple subsprites were co-located - i.e. had the same position (which is a CENTRE position), even if this meant they had a lot of transparent content in them.
<P>
Once you do that, however, there's no longer any need for a composite class. You just mirror certain characteristics of the main sprite (position, scale etc.) on the subsprites, eliminating the need for a composite class.
<P>
Easier still, make the main sprite and the principal subsprite as a single sprite with all the necessary animations - say, the boat and its wake, and use a separate sub sprite for each of the other animations required.
<P>
So, long story short, no composite sprite class.Gilhttp://www.blogger.com/profile/08021058996570815548noreply@blogger.com0tag:blogger.com,1999:blog-6419069426408917488.post-7663365545766654722012-10-28T15:46:00.000+00:002012-10-28T15:46:35.720+00:00Another Idle MonthI've done no more on Jade in the last month - Real Life intervened.<P>
I'm now ready to start setting up a more satisfactory demo version with some interesting action, so I'll be working in Povray a lot - a condition that isn't conducive to much reporting from me.<P>
I'd like again to appeal to anyone who wants to collaborate on the Povray side. I'd be delighted to share the load and the credit with you.<P>
Meanwhile, and this is the problem with me, I've seen another possible use of the Jade engine and I keep thinking about that instead of getting on with what I should be doing! <P>
(below) Junk sprite with bluescreening.<P>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdAMQM_s07Osyf5pLyHRiO4FhAxQg865WH33gZuWU3DVbE6_oYGszNLEUFnslxk8el7OrYOGjiReO04Yc6sdMj-5ig-Q8cJviRb053IW4tYFFL0wrwZKR9dbqID1m2hakG_USpLBwxPTVr/s1600/junksprite.png" imageanchor="1" style="margin-left:1em; margin-right:1em"><img border="0" height="80" width="89" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdAMQM_s07Osyf5pLyHRiO4FhAxQg865WH33gZuWU3DVbE6_oYGszNLEUFnslxk8el7OrYOGjiReO04Yc6sdMj-5ig-Q8cJviRb053IW4tYFFL0wrwZKR9dbqID1m2hakG_USpLBwxPTVr/s400/junksprite.png" /></a></div>
Gilhttp://www.blogger.com/profile/08021058996570815548noreply@blogger.com0tag:blogger.com,1999:blog-6419069426408917488.post-32140779764373601742012-09-18T18:00:00.003+01:002012-09-19T16:19:13.607+01:00Example GameFor the morbidly interested, I have uploaded the current Alpha version of Jade as Jade.apk, available from <a href="http://amazonsystems.phpzilla.net">http://amazonsystems.phpzilla.net</a>.<P>
This is a "game" with just six scenes, and very little to do except pick up a candle and drop it, but the music and sound effects are there, and the options.<P>
Try it if you dare. Actually it is very benign as alpha versions go. Other than its own running space and private data, it only uses the media player, and surrenders or pauses that whenever it loses focus.<P>
It works for me on my Android Xoom, but I'm interested in the behaviour of other platforms.<P>
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQJ7ZIZEdpEhJHOp7YCzDau2emr0T0-KSuwBybAUtUf1nORMuXOo8htjkt3veu-ULDMQ2CRMLyW7hwd9mFibCGse39jObcmhd08eVmqbfsghwJlTL0SJDm9EoUueJGcX9zObNL-lTIeyub/s320/Image18.png" imageanchor="1" style=""><img border="0" height="55" width="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQJ7ZIZEdpEhJHOp7YCzDau2emr0T0-KSuwBybAUtUf1nORMuXOo8htjkt3veu-ULDMQ2CRMLyW7hwd9mFibCGse39jObcmhd08eVmqbfsghwJlTL0SJDm9EoUueJGcX9zObNL-lTIeyub/s320/Image18.png" /></a><P>
From left to right the options are Quit, Restore, Save, Music On/Off, Inventory, Pause.
<P>
Double tap to pick up and drop the candle.
<HR>
Sparing no expense, the source is also available at the same address.<br>
<a href="http://amazonsystems.phpzilla.net">http://amazonsystems.phpzilla.net</a>
Gilhttp://www.blogger.com/profile/08021058996570815548noreply@blogger.com0tag:blogger.com,1999:blog-6419069426408917488.post-19588320899785774382012-09-17T10:28:00.000+01:002012-09-19T17:48:49.147+01:00New Touch protocol in placeFor once, it took more time to flowchart this than it did to implement it, but I can now reliably detect click, longpress and double click. I've changed to double click for for pick up and drop. It seems to cause less finger trouble.
<P>
The next activity is definitely the prototype game. I've got all the elements I need in the engine now, I think. I just have to use these capabilities to write an acceptable mini game.
<P>
I've been a little disappointed by the appearance of some of my backgrounds on the Xoom. I'll experiment with less compressed jpg files.
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg22ulcNdXHTTALZFU7BoxJUQg2RMi0P8q0eor3Vv1FDGmJ3pvtvxKtnxQq_0GrPcDFekxmf2YZdTkdud3Jay80qpMlp2zNuB9BNFmbmCewN7GIWG7snhPfAgjFr5qubfA4XfjFjEPQhSaH/s1600/junk202.bmp" imageanchor="1" style=""><img border="0" height="300" width="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg22ulcNdXHTTALZFU7BoxJUQg2RMi0P8q0eor3Vv1FDGmJ3pvtvxKtnxQq_0GrPcDFekxmf2YZdTkdud3Jay80qpMlp2zNuB9BNFmbmCewN7GIWG7snhPfAgjFr5qubfA4XfjFjEPQhSaH/s400/junk202.bmp" /></a>
Gilhttp://www.blogger.com/profile/08021058996570815548noreply@blogger.com0tag:blogger.com,1999:blog-6419069426408917488.post-18118373767454621002012-09-07T19:32:00.000+01:002012-09-17T10:36:11.230+01:00Jade SoundI have now implemented a JadeSound class that seems to be working very well. There WAS a hitch in the use of MediaPlayer.
I kind of assumed that when you called MediaPlayer.release(), the instance of Media Player would be set to null. Not so.
Although a failed create set mp to null, if I reset and released the mp, and then didn't create a new one, the next time I entered the method, mp would still have the value of the released mp and a new reset() caused a fault.
<pre>
package uk.co.amazonsystems.jade;
import java.util.ArrayList;
import android.content.Context;
import android.media.MediaPlayer;
import android.media.SoundPool;
import android.media.AudioManager;
public class JadeSound
{
// This class handles all sounds. There are two sound sources. Use soundpool for short
// transient sounds. A single soundpool does all the sounds.
// For background music and ambient sound, Use MediaPlayer. Each sound is a new mediaplayer.
// Only one sound can be running at a time. All such sounds are looped.
public static final int OK_SOUND = 0;
public static final int BAD_SOUND = 1;
public static final int NOSUCH_SOUND = 2;
public static final int BAD_PLAY = 3;
private SoundPool soundpool = null;
private static int CHANNS = 4; // Sound Channels
private String soundName; // current ambient sound name
private int [] SFX = new int[CHANNS]; // Stream IDs
private int priority = 1;
private int soundid[]; // Sound IDs
private Context thiscontext;
private MediaPlayer mp;
private ArrayList <String> soundfiles;
private int buggins;
private boolean soundstate = true;
// Initialise
public JadeSound(Context JadeContext, ArrayList <String> SFXFiles)
{
thiscontext = JadeContext;
soundfiles = SFXFiles;
if (soundpool != null) soundpool.release();
soundpool = new SoundPool(4, AudioManager.STREAM_MUSIC, 0);
int temp = soundfiles.size();
soundid = new int [temp];
for (int ii = 0; ii < temp; ii++)
{
int resid = getRaw(thiscontext, soundfiles.get(ii));
if (resid == 0)
{
soundid[ii] = 0;
}
else
{
soundid[ii] = soundpool.load(thiscontext, resid, priority);
}
}
for (int ii = 0; ii < CHANNS; ii++)
{
SFX[ii] = -1;
}
buggins = 0;
}
public int playSFX(String name)
{
return playSFX(name, 0);
}
public int playSFX(String name, int Loop)
{
int index = soundfiles.indexOf(name);
if (index == -1)
{
return NOSUCH_SOUND;
}
else
{
soundpool.stop(SFX[buggins]);
if (soundid[index] != 0)
{
int reply = soundpool.play(soundid[index], 1, 1, priority, Loop, 1);
if (reply == 0) return BAD_PLAY;
SFX[buggins] = reply;
buggins++;
if (buggins >= CHANNS)
{
buggins = 0;
}
}
else return BAD_SOUND;
}
return OK_SOUND;
}
public int playAmbient(String name)
{
// if the same sound name, just exit immediately
// we use the same mp we used last time, and keep playing the same song
if (soundName != null)
{
if (soundName.equals(name))
{
return OK_SOUND;
}
}
// if the media player still in use, reset it, release it and null it
if (mp != null)
{
mp.reset();
mp.release();
mp = null;
}
// remember the new sound name for next call
soundName = name;
// find the sound file in raw
int resid = getRaw(thiscontext, name);
// if it's not there, return
if (resid == 0)
{
return BAD_SOUND;
}
// Finally, create a media player
mp = MediaPlayer.create(thiscontext, resid);
// if it doesn't work, return
if (mp == null) return BAD_SOUND;
// Ambient always loops
mp.setLooping(true);
// start the playback
mp.start();
// if the song flag is false, pause it
// we may have to start it later
if (!getSoundState())
pauseAmbient();
return OK_SOUND;
}
public void pauseAmbient()
{
if (mp != null)
{
mp.pause();
}
}
public void resumeAmbient()
{
if (getSoundState())
{
if (mp != null)
{
mp.start();
}
}
}
public void pauseAll()
{
if (soundpool != null) soundpool.autoPause();
pauseAmbient();
}
public void resumeAll()
{
if (soundpool != null) soundpool.autoResume();
resumeAmbient();
}
public void closeSound()
{
if (soundpool != null)
{
soundpool.release();
soundpool = null;
}
if (mp != null)
{
mp.reset();
mp.release();
mp = null;
}
}
public void setSoundState(boolean state)
{
soundstate = state;
}
public boolean getSoundState()
{
return soundstate;
}
// Helper method that translates a filename in res/raw to a resource id
public static int getRaw(Context context, String name)
{
return context.getResources().getIdentifier(name,
"raw", context.getPackageName());
}
}
</pre>
Gilhttp://www.blogger.com/profile/08021058996570815548noreply@blogger.com0tag:blogger.com,1999:blog-6419069426408917488.post-6692947207349507732012-08-31T12:37:00.000+01:002012-08-31T12:37:15.292+01:00I'm horrified...... to see that it's taken a whole month to get a new Mythaxis out. However, here we are today, ready to roll. <UL>
<LI>First up, a new sound class. Sound was giving a lot of trouble.
<LI>Next, a better long press implementation.
<LI>I've been giving consideration to the concept of never displaying a background bigger that the original, to avoid jpg artefacts.
</UL>
Gilhttp://www.blogger.com/profile/08021058996570815548noreply@blogger.com0tag:blogger.com,1999:blog-6419069426408917488.post-19833291022982268722012-07-28T21:01:00.000+01:002012-07-28T21:05:14.654+01:00A HesitationI must get on with a new edition of <a href="http://www.mythaxis.co.uk/" target="_blank"><b>Mythaxis</b></a>, so I'm pausing a while.<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://www.mythaxis.co.uk/" target="_blank">
<img border="0" height="75" src="http://www.mythaxis.co.uk/banner1.jpg" width="320" /></a></div>
<br />
<br />
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.Gilhttp://www.blogger.com/profile/08021058996570815548noreply@blogger.com0tag:blogger.com,1999:blog-6419069426408917488.post-59933945280134031782012-07-23T11:39:00.001+01:002012-07-23T15:20:46.956+01:00Music Design UnsuccessfulWell, my sound implementation was not a great success. Some of it worked, some didn't, despite close monitoring on debug that the right things were being called with the right parameters. Specifically, <b>setLoop</b> didn't seem to work, nor did <b>pause</b> nor <b>autopause</b>. Most of the problems were with the background music and ambience sounds. The simple sound effects were fine.<br />
<br />
I note a lot of such mysterious problems on Stackoverflow, and I may change policy here. <br />
<br />
Also, I think it should have been a <b>class</b> rather than a <b>method</b>, and I'll re-write it like that. I may also have to use the <b>MediaPlayer</b> for longer music and the <b>Soundpool</b> just for immediate sound effects. We'll see. MediaPlayer is facility-rich, but seems rather complex to use.Gilhttp://www.blogger.com/profile/08021058996570815548noreply@blogger.com0