Monday, April 22, 2013

prototype

http://www.youtube.com/watch?v=NV9pYrH4qF8


The map is parsed from a data file. One layer for the map and another layer for the objects. The map scrolls, I have a touch and drag scroll working in another version but need to program the touch events in a better way.
The tiles are animated with animation class with a variable framerate per object and a dynamc list of frame uv cordinates and A-star pathfinding working.
Time for another rewrite  hmm....maybe combat can be hacked in before that.
As always any comments are welcome.

On to something different...Timers

Having spent dozens of hours programming in Codea I 'm getting the handle on how versatile tables in LUA are.

They are fast flexible and best of all can be created on the fly. I have to create a timer class to assist with animating texture mapped quads. The animation system is in and based on the animate class and I need to merge it with an timer class found here: http://twolivesleft.com/Codea/Talk/discussion/2585/timer.

animationName=Animation(id,{vec2(x,y),id,{vec2(x,y)...,duration})

I will need to register the newly created animation with the animHolder {} -- list
after the animation is created then send the animation name to AnimHolder

Sunday, April 14, 2013

And More TIles

This is just going to be a quick dump of what I have programmed today.

Ok, here we go.
The data structure of the tiles is solid
There are 2 drawing layers. The map and the object on the map
The tile is a dynamic size and can be changed in realtime, and can be scrolled by tile size.
     the player can be moved by fragging your finger over any open tile (taken from the map  
     Grid.tileType variable

Tomorrow I want to be able to import the map from the tiled editor and move the character around the screen.

Tuesday, April 9, 2013


I have rewritten the class that creates the map tile. I now have the ability at run time to change the number of tiles displayed on the x and y, and their size in on the fly. This is the base code for developing different resolutions on varied devices. It took some time but all the main parts are in and working.

My next step is to get a second layer drawing on top of the base map. It will contain a list of objects. For example,  the player, weapons, enemies, ...
     player = player(pos,health,move,attack,defense,isActive,IsDead,moveList[#,pos])
     The moveList is the returned x and y cordinates from the A-star function

Just a quick update bease the next episode of Game of Thrones is calling me.

Friday, April 5, 2013

Tiles and polygons and hash tables oh my!

I have been getting a better grasp on the mesh function in codea. A light just went off today about how this works. The quick of it is when you add a new rectangle the mesh it gets an index number. To target rectangle you need to store this reference number.

On the codea forums someone created a hash table to store the mesh and it's rectangles and functions to 
add and remove rectangles. 

Use meshNewRect(myMesh, x, y, w, h, [r]) instead of myMesh:addRect(x, y, w, h, [r]), To remove the rectangle  use meshFreeRect(myMesh, index.

For example:
map = mesh()
for x = 1 to 10, do
     for y= 1 to 10 do
          mapList[x][y] = addTile(meshNewRect(myMesh, x, y, w, h, [r], tileName,health,blocksLOS,visible)
    end
end

This way you acccess the mesh throught the mapList x and y positions. modifying the rectanges position, size and texture cordinated are simple. wel as simple an any programming can be.

Next to inplement this into my game framework.

Tuesday, April 2, 2013

The Evilness of Programming a Multi-touch Display

Don't get me wrong, I love using my Ipad. The joy of dragging things, tapping the screens in games, collection dropped loot. All these thing have a tactile feel to them enhancing gameplay. Now the down side. It is a pain in the rump to program for these actions. Here is a simple breakdown on my touch events.

trap begin touch
     is the begin touch player --- are you going to drag to move, do you just want to get the player
                                                  info or just show the tiles where they can move.
     is the begin touch the menu ---
     is the begin touch enemy ---
     is the begin touch a unexplored tile --- is the tile adjcent to the player, if not ignore and wait for
                                                                   ended state to begin moving the player
     is the begin touch an explored tile --- display tile info or move the player (to be determined in
                                                                 prototype)
     if the tile is the inventory button or pause, or a action card or inventory slot

check moving touch state
     if selected object is dragable -- set begin x y position of object
                                                   -- set begin touch x and y and subtract current touch x and y for tile
                                                      offset, then check screen cordinates for dragable area and end drag
                                                      is outside of the defined area.
     if not dragable ignore the moving touch
     if a map is dragable dag all elements in the map to add dragOffsetX and dragOffsetY so they move
     together.

check the ended touch state
     if a dragable object was moving and released on a target object save target object and process the
     correct reaction to the release state.
     if object is released on a non target reset the position

This basic outline is just for a single touch and not a 2 finger rotate, or a pinch zoom, and I don't even want to think about a swipe gesture system.