Last Good Quote: Son's are the seasoning on our lives. - Someone on Facebook

Friday, February 9

War Game Update

So I did a little coding. It actually didn't take me near as long as my estimates came out to be. I've put the new time at the bottom and revised the rest of my estimates. Enough about the mundane though. Here's a few things I learned/decieded.

Instead of creating an agent object and creating an array of those. I used a collection of arrays. I know, I know half of you are cringing at hearing that. Now normally I'm all for OOP goodness but as I implemented it that way. I found that there was a huge lag when it came time to paint the map with the agents on it.

I'm clearing the map, then painting all the agents on the map. Of course this means I have to loop through the array of agents, then calling the property object. You don't realize the overhead until the screen starts to lag.

Lesson Learned. I went back and created a number of array's that hold agent information. Something like the following...

Dim agentID(0) As Integer
Dim agentOwnerID(0) As Integer
Dim agentX(0) As Integer
Dim agentY(0) As Integer
Dim agentDestX(0) As Integer
Dim agentDestY(0) As Integer
Dim agentWait(0) As Integer
Dim agentAttWait(0) As Integer
Dim agentIsAttacking(0) As Integer
Dim agentSpeed(0) As Integer

Interesting huh...we will see how much this cost me in the long run.

I also built a quick push function which will put an element on the end of the array. It's rather simple and there probably is a much better way to do this.

Function pushInt(ByRef arr() As Integer, ByVal v As Integer)

Dim tmp(arr.Length + 1) As Integer
arr.CopyTo(tmp, 0)
tmp(tmp.Length - 1) = v
arr = tmp

End Function

Anyway at this point users can login, register, select thier unit, move it, and shoot an enemy unit.

Each unit will wait 10 seconds before it becomes active again.


Post a Comment