Tuesday, July 23, 2013

Back up after a needed break

I know it has been a while but I'm back. Work has progressed on the movement system. I will let the video do the talking :) The red box is the screen touch.

video

The player can detect adjacent zombies and call the player:giveDamage(recipient,damage,time). Tomorrow I will have the first draft of combat. Fingers crossed.

Thursday, June 20, 2013

I just took a break from the "code"

For anyone who finished a large programming project my hats off to you. I saw the forrest of my doom... regrouped, and formed a frontal attack. I hacked in some combat, mostly finished the anination class. The zombies will attack and destroy doors if they are chasing you. There is no visual cue to show damage being taken and I will need to make some temporary visual for that and I must seperate the movement of the player and the enemies to seperate timers.

I used my first method with varargs for this. So, player:adjustDamage(-1,-5,2) will pass a list{-1,5,2} as an argument to be added by the method function Player:adjustDamage(...). This rocks. A good example of it's use is damage to a zombie standing in fire and being shot while eating flesh. From the previously defined adjust:damage(-1,-5,2) we see the total adjusted damage wound be -1 + -5 + 2 = -4. It makes damage a number to be generated in the weapon class and environmental class. I will not have to write(accept in this example): if fireDamage ~= nil then totalDamage += totalDamage fireDamage end. I need see if I pass in a list will it make a list out of my varargs, or can I just loop through the passed in variables.

I will have a video soon and I will demonstrate some combat.

Friday, June 14, 2013

The need for animation states

I am modifying the animation class adding a nested list of the animation frames with a string labeling the animation name. For example, createAnimation({player,"walk",vec2(1/10,9,10),vec2(2/10,9,10),vec2(3/10,9,10),animationSpeed,
                             isPlaying},
                            {"attack",vec2(4/10,9,10),vec2(5/10,9,10),vec2(6/10,9,10),animationSpeed,
                             isPlaying},
                            {"idle",vec2(4/10,9,10)animationSpeed,isPlaying}})
Each vector2 is one location of the UV map and the string is used for targeting the animation cycle. animationSpeed is pretty obvious and isPlaying is the flag to run the animation. This gets added to the player object, defined as the first argument of the method, for easy reference. It is a bare bones animation system that checks the passed frames for the animation timing. So, an animationSpeed of 30 would be a 1/2 second at 60 fps. Once I have the control of the animation refactored the interface need some love.

I really need to address the interface elements sooner rather than later. I have the square you touch highlight, and if you drag your finger around will snap to the corresponding square under your finger. It has a good feel to it :).    Not enough change to post a video but the it is first interface element I have build and many integration questions have come up. That will need to be another post.

Wednesday, June 12, 2013

The Trouble With Doors

Using a tilemap to generate large maps is awesome, but there are some drawbacks too. The first drawback is doors. My first iteration of the map needed a hall to connect one room to another. This illustration proves this point.


My first pass at a map with a more schematic view introduces the door factor. I am glad I took some time to generate this graphic because now a door can be on any side of the tile.


Each tile can have the potential of a door on any of it's 4 sides. A tile will need to have a door property, up down right left, and will have some logic to determine the players direction going through it. The door, nearest the player is looks similar the the above map accept it only takes 2 tiles instead of 3 tiles to display. An open door will be considered open for shooting Line of Sight and for movement but a closed one will block both. This creates some issues with the pathfinding because now a tile can have a enemy in it and not be passable. Hmmm. I think a second pass checking the property of the current tile and the next tile in the path list, with some condition statements, will fix this. Looking at shared walls more pathfinding issues based on the grid show up. I will need to come back to this or scrap it for this version.  On second thought...doors are OK, and shared walls are out. 

Thinking more about doors and walls I will come back tp both later. I need to keep focused in finishing the the ai, game goals, bug fixing before I change the scope of the astar pathfinding. 

Sunday, June 9, 2013

It was supposed to be just a bug squshing day, but...

I started with the desire to squash some bugs and then worked on some prototye placeholder art for the zombies instead. So, here they are


It took about an hour for them. I am going to integrate them in the game now. I was tired of looking at red Z's all the time.

Here is the first implemention of the zombie tiles.

video

Now I need to update the Animation class to use more than one animation list of frames

And now there are 2 zombie types.

video

Friday, June 7, 2013

One last Pathfinding Bug to Fix

The enemies, within a specified distance, will move to the players position. The AI Update searches  every 3 seconds for the player and if the player is not found then they will move a random direction. There are few issues I need to resolve. First, the path finding chooses a path that ends next to the player and not the exact position of the player. This is OK for now because the player and enemies will not occupy the same tile, but needs to be fixed. Secondly the player and enemies move on the same timer causing their movement rates to be the same. Separate timers will give me better control over them. The last thing I need to fix is the AI should not move a random direction if it is within the AI path finding radius or moving toward the player.

Things I need to implement:
I need to think about how sounds will effect the AI
How to have attractors lure the enemies away.
Make enemies and players not walk over each other
The art direction of the game
Combat
Interface
and the actual game play
Here is another video
. video


Tuesday, May 28, 2013

My First Go at AI

The main driver my AI routines is the distance the player is from an enemy. The visible board size is 10 tiles now and the total map size will vary from level to level. A distance value of 4 is the starting point for the enemies to activate. It's an arbitrary value an will probably change in the near future after some play testing. The trick here is to balance the timing of the enemy movement with the player movement. Right now they all move at the same speed. See the video below.

video

This is my first attempt at tracking an object. There are some issues with the AI timer firing while the enemies have a target. For a first pass it is a good starting place.

Everything is going to be event driven. I have 2 timers now. One for the object movement, firing every 2 seconds, and the other one is for the AI to update the movement. Currently the AI has a nasty show stopping bug that I will need to address. When it fires the second time, after a distance check from the player, the Astar start and end values are getting set to nil somewhere. (Print statements here we come). I need to separate the enemy movement out of the object timer and make it independent. The choice I need to make is a hard one. Do I have every object have timed value and a running timer, or several timers at different intervals. I think the latter is less processor intensive and will allow swarms of enemies. A running timer would need to check every object every frame or have a way to register objects and their fire time. Time will tell.

Monday, May 27, 2013

The pathfinding bug is dead...Long live the pathfinding

For the last week I have been sick with a sinus infection and could not concentrate on programming, but yesterday I found the pathfinding bug. It is the small things kill you in programming. When I called the pathfinding method it worked with one object but when I used it on more than one object all hell broke out. Part of it was me and part of it was me and part of it was Codea's debug printouts. The error was with the object using the same path for everythinig. I first thought the list copy function was not working but I was using the same path for everything. A simple change from path = listCopy(path) to v.path = listCopy(path) fixed the error.

The only other bug related to movement is when he map is scrolled the pathfinding checks the wrong cordinates. That should be relatively easy to fix

Tuesday, May 21, 2013

Fighting a loosig battle with Codea Debugging

If you program for the Ipad with Codea then you are familiar with the print statement. The debug tools is a command line(a good start) and runtime errors that may or may not point to a relative piece of code. As a former Flash programmer I love the flexibility LUA has with data types and functions. I wish I was an uber programmer; to take advantage of coroutines and passing in functions as an argument would rock. But alas, this will not be. I guess the reason for this rant is I hate debugging. It's  probably a sign I'm a smart guy who can program, and not a programmer who is smart. Add in a time based play mechanic that can be real time or fire off timed intervals.

The mantra of every article I have read states, "Build a simple game first". I agree and all, but will I not follow that advice. If i am going to go through this grinder of a process then it had better be worth it.

On the programming front:
debugging the astar pathfinding return value are assigning wrong when called repeatedly.
The aster will not search the correct start and end values when the map is scrolled
Fixed various player movement issues with touch movement.
Decided to not add a mesh pool for dynamic enemy creation.
Enemy AI now knows when you are within 5ish squares of them and call a path to you. then start to move to your location. Still some major bug to squash. Arrrghhhh! So close


Monday, May 20, 2013

Realtime movement is a pain to keep track of

Today I was working AI of the enemies and I have several flags assigned to the player class. Every non-map object is a player and the tileType is keyed off to get see what tile it is. For example,

2 = Player
3 = enemy
4 = open
5 = Point of Interest
...
player = Player(id,tileType,isActive,target,path,pathCount)

The AI checks if the tileType is an enemy and then checks if the the distance to the player is <= the activation distance. The enemy then calls the astar to the position of the player and returns a list of coordinates. This path is assigned to the player.Path list and is updated every enemy clock cycle, currently 2 seconds(enemy speed). When the player/enemy moves path count is updated and the character moves closer to the target. When the target is reached the list is removed. A few bugs not withstanding it works. But when the player moves the enemy AI does not adjust to the new player location. I do not want the enemy to poll the player position every draw call and it would be good to update the pathfinding when an enemy is moved.

I will post a video when I get something working.

Saturday, May 18, 2013

Too 3D or Not to 3D

While reading a blog, project zomboid 's I think, there was a discussion on the amount of frames it would take to animate the characters. It was in the thousands. Not even possible on a Ipad. This thought arrived while programming the movement on the game. The current movement is tile based and the character moves the entire width of the tile. See the videos in previous posts. I think I want to have pre-rendered 3d characters, very low poly, and 5 frames of animations per character. It would not be wise to have your first project contain any 3D. Programming is hard and programming 3D, while possible, is harder out of the scope of this project.

I have not written about my background before. I studied fine art at Arizona State University, have programmed Flash professionally and was a professional comic book colorist.  Here is an old portfolio from 2006. http://www.freewebs.com/vidopiac/ My introduction to programming was a Pet CBM learning Fortran and Pascal in the mid 80's. I had a Mac 128 and an Amiga (awesome machine). On the 3D side I am a decent box modeler, and texture artist. I use Modo for 3D and on the 2D side I use Photoshop, Procreate, and Artrage. 

The 3D can be done me, time permitting. 

TO be contiued... Star Trek is calling me.... Phasers on Awesome

Thursday, May 16, 2013

More thoughts on movement

This post will be mainly be about player movement. Currently I have the player move when you press to select the player and drag your finger to where you want him to go. This works fine but it leaves your tacticle options at the mercy automatic pathfinding. To fix this I will add the ability to select,an empty tile next to the player, and draw your parth the  player will follow. The tiles will so show they are selected. so you can see the path. To stop the movement early tap the player to stop or maybe drag another path and clear out the old one. It should be easy to implement  and when I get home after work I will try it.

Monday, May 13, 2013

Movement is in with lots of things to fix

It is not as bad as it sounds. I have the Astar pathfinding working with the character and a flag goes off when ever the player walkes over a game object. The idea is every time the game clock fires the enemy will move. The enemies check a random direction to move one square and if that position is a walkable tile then the enemy moves. I need to also check the list of enemies to see they don't walk over themselves or other things that block movement. This is the starting state of an enemy and when they are activated then calculate the astar to the point of interest

I also need to start a thinking about the z sorting of the objects and get rid of some troublesome bugs.
Another video


video

I speed up the time so you can see them move in the green walkable areas

Food Will Have To Wait

While implementing the movement for the character I needed to decide what to do when the character moves over a tile that is not an enemy. Every game object is drawn above the map and when you walk over it I currently set the uv cordinates to a transparent and it dissappears without having to translate it or destroy it. This is not the best solution, but I design on the fly, and I feel a pool of objects is needed so I can just reuse the objects and save cpu time creating and destroying them on the fly. This will help when I need rectangles for a particle system (you can't have a zombie game without blood splatter) or with dynamically adding game objects to avoid memory leaks.  

Here is a video of the objects being removed and rember this is pre- alpha.

video

Well I need to go to my day job. One day I hope to make a living from game development 

Sunday, May 12, 2013

A thought about movement.

I was thinking about how movement would work in my tile game. As the map is right now it is tile based with a total map size of 100x100 and a visible area, the actual tiles you can see, about 10x13. The game starts with the map entierly black and as you tap the adjacent tiles to the player to reveal the map. Think the gameplay for Dungelot, http://dungelot.com/, on how to reveal the tiles. Revealed tiles have a chance of giving something usefull for gameplay. I am considering two ways to implement the movement/tile reveal mechanic.

First, the payer has 5 reveal points and 5 movements points to use. As you reveal reveal tiles those tiles become available to move to. If the player has no more reveal points they must use their movements up before the reveal points are reset. This design leads to the player turtelling up, revealing all of the map and missing the sense of urgency a survival game should have. The player has the right to do this and it is my job to make if fun for them.

The second way, reveal as many tiles as you want before moving but for every tile removed the chance of an enemy appearing randomly will increase. This way you force the player to keep moving and they can still loot tiles with out moving if they choose. This brings up a point of what besides surviving will push a player to give up their comfortable kill zone on the map. If the walking dead has tought us anything about zombie survival --then the answer to this question is FOOD.

The next post will talk about how Food is being inplmented in the game

Saturday, May 11, 2013

Project Z update

I know there are hundred of zombie games out there. Why would I make another one. Well, because I want to. Every article I read about indie game development states I should make a game I want to play. I want to play a rouge like zombie survival base building game with some secret sauce to make it unique. On to the game update.

The timer is in but needs some work with looping.
Selection of game objects is working and I need to process the begin touch and end touch on the map
I had multiple objects working with the astar pathfinding but the second object had it's start position get mixed up with the the last object that called the pathfinding routine. I need to implement a queue so I dont have 2 pathfinding routines running at the same time.

Things related to movement:
     the position of the objects need to be checked before a player or enemy is moved.
     If the player has a ranged weapon and taps on a enemy calculate the line of site.
     If the player is adjacent to a corner wall the damage of a ranged attack will be halved if the wall is
     infront of the player.
General things to think about:
     the interface
     the player inventory
     exploration of the map
     implement the button class
     the role of NPC's
     fire and how it can spread and damage tiles
     same screen multiplayer

ios apple indie game development games

Monday, May 6, 2013

Still no fun yet but...Progress

Thing on the next up list:

The timer is being re-examined to see the proper way of implementing it with the game objects. The game objects have an animation class attached to them and I will also attach the timer class.  After I figure out the callback routines used in the class I am  using.

A gameState for holding various game controlling variables.
    currTile to tell what tile to animate/show selection
    prevTiles to tell the last selected tile to stop from playing the list of UV cordinates and go to the
    initFrame.
    gameState playing, menu, paused, map, gameOver, splashScreen.
 
The game timer will fire every 1 second but it is a variable and can be changed
     the enemy timer will fire every 5 seconds to start
     this will decrease with the noise level
     the enemy can move or attack but not both
     the hero's energy variable will add to the enemy timer
     the hero's will move every second as a baseline

Need to implement the "Secret Game Play" map and inventoty stuff.

The a-star and los fire needs to be reimplemented

First I need to get the checkNeighborTile working when it finds something in the grid[][] map

ios ipad games lua development

Thursday, May 2, 2013

Bug fixing and cleanup

I took a week off from programming, it is a part time hobby of mine, and now I am ready to attack the next set of issues. One bug that killed 5 hours of productivity is finally dead. I use counters to add rectangles to my map mesh. So, 1-100 are the tiles of the map and counter 1000 on up was for the items and player and enemies. I found out the hard way there can be no gaps in the numbering of rectangles being added to the mesh. If you have a break in the numbering then the rectangle shows up and is textures with the whole image map. As soon as the numbering was sequential without gaps...poof texturing worked.

The next issue is the tileType id from Tiled map editor needs to be hard coded so the map draws the correct objects.

Thing I finished:
Game Timer is in with start and stop events on and individual
animate objects with their own framerate
map scrolling in the x direction now works correctly tile updates

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.

Saturday, March 23, 2013

Where to start?

I started off this project programming LUA in program called Codea. It is an awesome product, but it needs a bit of love in the sound department. With this being said, Gideros, is another program with sound support and better event handling. I will need to make the switch, some time soon, but it is just too cool to program on an Ipad with a Bluetooth keyboard.

I also dabbled in Unity, also a quality product, but again you need a Mac to make an ios game.  Programming in LUA is too much fun and for a the 2d game I want to make it makes sense.

The next post will be the inerrant evil of programming a multi-touch interface

Tuesday, March 12, 2013

First Post

This will be my journey creating my first IOS game with the program Codea. I come from a graphics background and have programmed Flash on some large projects for Cisco Learning Interactive (CLI). While creating this game I am also learning LUA at the same time.

The Game will contain:
     A tile based top down map
     Discovering tiles
     Be an educational tile about Addition, Subtraction, multiply, and divide.
     Movement will be a floating move circle
     Use a Sprite Sheet and have animated tiles.
     Targeted towards 2nd to 5th graders

My first step is to get the tile map system working with dragged scroll area, created with an grid
array for the content.