Wednesday, October 12, 2011

AFL game coming ideas

Coming ideas
  • Football should get bigger as getting to mid point, smaller to ground (to simulate 3d)
  • Football is current a red circle, should be an oval. Should also be spinning like a drop punt
  • Leading player should randomly lead in a direction to make us have to work to hit his lead
  • Leading player should react after ball is kicked. If it’s kicked anywhere but perfect, they try to time their run to hit the ball. If they have to change direction, look at the physics of doing so. Player should aim to get ball at head height, but could decide to get it lower if they can’t make it high.
  • Once leading player can change direction, introduce opposition player. They initially follow the leading player, trying to get right on him, then same AI as leading player to get to ball at head height.
  • Marking AI. Leading player hits ball with a nice gap, great chance at a mark. Close gap more like a 50/50. No gap still a 20%. No gap where player had to stop or slow right down no chance.
  • Kick to leading player gets more accurate the shorter the kick. So if you try to “cheat” and kick it asap all the time, innacuracy of kick should cost you.
  • Game includes a shot at goal. Similar to above, goal chances get lower as player is further out and on further angle.
So the simple game idea. Try to hit leader with perfect kick. They line up for goal. Scores add up over 1/2/3 minute game (or perhaps kick 5 goals in a minute, go to next level). High scores needed somewhere here. Should be a lot of fun, and only the first simple stage of this game.

Advanced features:
  • More players. Rather than one leading player, there are 3 players with opposition players. 1 or 2 of them lead, other doesn’t. Opposition players can spoil, can also leave there player to spoil.
  • Not over at spoil. Over at mark by you, mark by opposition.
  • Ball can bounce. It can keep going out of bounds. Players will go to bouncing ball still. If leading player has a gap when they hit the bouncing ball, they will turn around an snap at goal, likeliness of goal depends on distance and angle again.
  • If opposition is too close, they get tackled and turn is over
  • Wind. Show wind meter somewhere, possibly with swirly wind possible in later levels.

Very advanced features:
  • Other players can team up. So a player picking up on the bounce can handball to opponent if in field of vision when about to be tackled.
  • If neither player marks, players go again for crumbs. Other players have likely come close, so heaps of teamwork theories needed here.
  • If players look very close, team mates will assume crumbs.
  • Crumbs more likely in front of player for short kicks, more random on longer kicks.
  • Players can lead and change lead if it’s not working. ie if they are getting caught, they can change direction to fool defender, or just stop and go back to allow team mates to lead. This might allow kicker to wait until player has no lead, then kick it over their head to get over comitted defender going too far to get back.
Many more ideas to come. Will start picking off small ideas one by one to get some momentum on the overall bigger task.

HTML5 canvas animations

Intentions:
  • Get some simple animations down

Summary:
Got a player running in a direction, then another player kicks to button click. The intention would be to kick the ball with the right timing to hit the lead. Plenty of ideas for where to go next.

Interesting Findings:
  • setInterval(draw, 40) will call draw function every 40 milliseconds where you can do a "refresh" of your animations
  • use addEventListener to add a click event to the canvas
  • in draw, keep one player running the lead by incrementing x and y, keep the ball going towards where clicked, if clicked yet.
Overall I was impressed how easy it was to do some simple animations. Looking forward to getting a list of requests ready and working through them.

HTML5 canvas

Intentions:
  • Investigate canvas control. Looking at drawing, images, moving objects
Summary:

Hit up a few web HTML5 canvas tutorials, found plenty of content in the first few pages, enough to get me started.

Interesting Findings:
  • getContext in javascript to get a 2d image area
  • fillStyle and strokeStyle for brush shapes and colors
  • moveTo, lineTo and paths for drawing a sequence of strokes
  • arc to draw arcs
  • drawImage to draw a PNG image file
  • clearRect clear all background for animations
Didn't have too many issues getting my head around simple concepts of HTML5 canvas control.

Tuesday, October 11, 2011

Starting throught about my HTML5 game

OK, about to start writing an AFL game, and wanted to start blogging about the experience.

Background

OK, I'm a programmer of 12 years, starting off writing windows apps in Delphi, then pretty much everything Microsoft has promoted in the .net world. I've also dabbled in side projects on mobile devices, windows mobile originally, then more android recently.

I've never completed a game, but always wanted to. My first choice was a modern version of Street Rod. I loved the gameplay of that game, racing guys and trading, selling and buying car parts and cars from the classifieds. I also loved the more recent car games (I'm talking about the late 90's), and thought putting together big game graphics with solid behind the scenes gameplay would make a complete game. I also loved the idea of a more realistic cricket game, especially a first person perspective. My skill in graphics programming was very lacking though and the project was too overwhelming to even start, even after gaining some 3D programming skills. Things didn't get better as games became more and more about realistic HD content, and less about simple fun games. I lost interest in the idea, and also in gaming with it.

Enter the iphone. Once again simple fun games were on the board. And people play these games for hours, even with a 3D realistic shooter metres away on their PC. I chose android due to the easier path for developers to get an app live. I used my skills to create a couple of demo work apps, never quite got around to the games.

But here is the time. I've been dreaming up an AFL app similar to the old Nintendo AFL game. It's simple yet a whole lot of fun. It is very far from perfect too, but getting an idea like this to and Android app shouldn't be that hard, I hope.

HTML5

HTML5 brings more to the browser plate than ever. But it then goes further again. You can deploy HTML5 code to android and iphone apps with a couple of tools like phone gap, if you really like the apps. At this point you don't have to maintain several codebases with each bug found or feature added, but once HTML source, with just a few different projects to deploy to different platforms. I think this lends itself nicely to facebook, google apps etc as well.

A further nail in this coffin is Windows 8 and Tizen. Windows 8 is very obviously making forward moves with HTML. Now you can access Windows API's and windows dlls from HTML5 code on the desktop, there is little reason not to get excited about HTML. Nokia and intel backed meego OS also recently decided to scrap their relatively new project (just made it to Nokia N9 phones) for a fresh project based around HTML5 frontends and extensible API's. An exciting project that sounds very much like Windows 8 at a high level. It seems only a matter of time then before android especially, and then apple eventually move into the HTML5 space.

I also toyed with the exciting Novell projects, which allow C# code to the Android and IOS API's, to be deployed to app stores. Especially the AI would be so much easier to write in a language like C#, but I still wasn't convinced about spending a lot of time writing more C# code, especially on projects that are quite a long way from the mainstream, where hurdles become harder to jump.

The Approach

Again, the word overwhelming still hits hard. This is graphics (on HTML whats more), which I'm not 100% convinced I'm capable of. It's AI, which while I know I am capable of, it's not to be taken lightly. This won't be a realistic 3D game, so player fun is 100% my focus. AI makes up most of that fun, where you mainly control one player, and 35 other players need to be "behaving." I don't so much care that every player is thinking like an AFL player, but more that it mostly makes sense, and is fun to play. Finally, getting the whole AI thing working on HTML is overwhelming.

So start small. I've decided to make a few mini games out of it, almost like a bunch of AFL training drills. The first game will be a kick to a lead game. The player kicks to a leading player, trying to "hit him on the chest", with an opposition player hot on his heels. The scores in this game come from your leading player marking and then completing a goal, which gets harder on angles or further out from goal. Advanced features might be adding a full forward line of players, and the ability to still make a goal if the ball isn't marked. To go even further, I will break down work into small acheivable goals, like making a player lead. I will blog about these small goals, and give out some findings about how that worked in the end.

Programming side will start off a MVC 3 web application at the project level. This mini game especially will likely just be a browser app. Any hi score related infomration I build will likely be just a .net c# app, while the game will be HTML5 canvas. I'll have to find somewhere to host all this on a windows server.

I will also likely keep revisions on a mecurial server for source control. I'm using one locally right now, but will put it to a server, to make it easier to get to, and also potentially host it publically to go hand in hand with this blog, depending on how serious I get with it. I'll also be investigating javascript unit testing, which I've never done before.

So this it, time to start. Blogs from here on will be focusing on small goals and how I found achieving that goal. I expect a lot of hard times, but I think as long as I'm blogging them honestly, and continue to code, the process will work.