Tuesday, November 29, 2011

Green Algae: Updates & Combat System

Health bar, obelisk,
summoning effect and monsters
Here are some recent screenshots of the Green Algae project. Progress so far is minimal as I was discovering how to use GLES20 for Android. Added a green health bar and summoning of enemies from the obelisks with a basic scaling circle for a summon effect so far. It's rudimentary but at least it is something. I used the same placeholder image for both the enemies and for the player avatar. So the avatar in the image is the one directly below the obelisk or the messed up wooden thing sticking out of the ground. I refined the map generation algorithm a little and put in sandy beach like outlines. Still have way too many trees there.


Accelerated Image Problem
I also fixed an issue with images not being accelerated, the problem being unknown but found when I got incredible choppy and low framerates after putting in the fullscreen switch. You can test if an image is accelerated like this
GraphicsConfiguration gc = GraphicsEnvironment
 .getLocalGraphicsEnvironment()
 .getDefaultScreenDevice()
 .getDefaultConfiguration();
boolean isAcclerated = 
 image.getCapabilities(gc).isAccelerated();
In order to get the images accelerated I simply switched them to being VolatileImages which did the trick but then it broke the fullscreen switching so I need to reload them when the switching to fullscreen exclusive mode, or use the fullscreen window and just scale everything to match the size without changing resolution.


Map Generation Changes
Map generation actively changes
as the map is being generated
Here is another screenshot, its the map generation preview which helped me debug a few oddities with the sand outlining piece and parameters. I have a bunch of primitive looking slide-bars that act as controls for how many islands and how large, long, and how much they vary when built. You can see my attempt at grass here and making it repeat well. Also my first attempt at an actual standing tree to align with the top-down style graphics, it needs work and a leafy version.


Combat System Snippet Work
So, after fiddling a little bit with trying to make the summoned monsters fight back I found that I am indeed in need of a combat system. So I started thinking about the design of it and what I wanted it to be able to handle. I have a few basic classes and interfaces put into a separate project so I can share it with all of you as a snippet. Currently the idea is to use the mediator design pattern having a CombatSystem class as the mediator to handle things like who swung first and what not, handle multiple Combatants (which are the Colleagues in the pattern). Asses damage and timing between attacks it seems like it will be a good way of handling combat and could potentially be used in a lot of different games. So hopefully have that working in a couple of days if I get time to work on it. Or it may have to wait till the weekend, my day job does get busy sometimes.

Other ideas
If anyone would like to share what types of systems they've used in the past for combat, I am sure people would find it very helpful. Thanks for reading, and if you have any suggestions for snippets or need help figuring out something that I may know how to do don't hesitate to ask in a comment.

Tuesday, November 22, 2011

A weekend with Android GLES20

So I spent most of the weekend porting my android game code from GL10 to GLES20 it's quite the endeavor especially if you've never worked with opengl shaders or matrices. Moving away from the matrix stack was about the hardest part. The shaders were easy to get a handle on all except for the texture passing bit since you don't actually bind the texture to a specific sampler it's done indirectly through the use of numbered textures and order of sampler definitions in the fragment shader.

I've worked with shaders before in a similar way with XNA so some of the concepts were familiar to me. The new part for me was getting a basic post-processing bloom shader to work. I got it now but apparently there are some techniques I have to research before I use it efficiently. But about the one thing that opengl offers that Java2D is without is additive blending which is extremely useful for a lot of great effects, of course you can create your own custom composite in Java for doing additive blending though performance might be an issue there.

But some of the things I learned in getting this to work are as follows,
  • One you need to setIdentity before filling in the transforms
  • You can use the Matrix.translateM, Matrix.rotateM, and Matrix.scaleM in sequence
  • If you want to translate for example from the last position in the matrix you need to multiply the matrix by the new translation matrix (problems with order of operations)
  • A problem I am still having is that of textures still appearing mirror or flipped and other such non-sense due to orientation issues.
  • Oh and you have to manage your own matrix stack, if you want to change coordinate systems to use local coordinates for a particular object.
I'll post examples and more details after the holidays.

Aside from that just getting ready for Turkey Day. Hope everyone has a good and thankful Thanksgiving!