Archive for category Games

Doodle Complete on Kongregate

After a six weeks waiting for sponsors on Flash Game License and a ridiculous bid of 75$, I decided to finally release my game Doodle Complete on the web. The 75$ bid was even more ridiculous than that, the bidder also wanted to collect the money from advertisement and release the game under their name on Kongregate and Newgrounds (well new grounds require the game to be only 700px height so my game won’t fit there…). So I decided to release it without sponsors and to at least get some information about advertisements revenues. I spent all day yesterday trying to get Admob working for the Blackberry Playbook (yes you can get it on your PlayBook now!), but I couldn’t really do it. I also made it available with MochiAds and to their distribution network which already gave me 2000 views, so that is good.

Now, it seems like people on Kongregate don’t really like the game because the controls are hard… Well I could do something there, but I don’t think it would make people go crazy about the game anyway. So I kinda decided to let it go. I’m going to fix the minor bugs, but I won’t put anymore time on this game and start working on the next one which will be more classical, little risks that people will complain about the controls.

Last thing I will do is try the iAd extension for iOs from Milkman games to see if those revenues are worth the trouble. I will have to pay 20$, but I guess I will have it for other games too.

Anyway go play the game on Kongregate and if you can give it 5 stars :)

, , , , , , , , ,

3 Comments


Little games for Lassonde based on Madagascar 3

Didn’t have much to show since I came back from the States, but here is a little project that was pretty fun to do. Fruite Madagascar 3. My part in it was to do the games: Burst-A-Balloon, Pin the zebra and Memory game.

Felt really good to have a project that didn’t become extremely complicated after a while :) . I used Robotlegs for all of them, and I reused a lot of code in each game. Seems like Robotlegs ain’t the preferred framework when building games, but in this case performance wasn’t really an issue so I liked it a lot.

, , , ,

No Comments


Optimizing Flash for the iPad

You might know that I am making a game for the iPad and it’s nearly done. The thing is, I also want to publish it on the web, you know, make money from sponsorship too. Actually, I think it might be the only way I make money with the game as the iPad app market seems really hard. Plus it will also cost me money to publish in the Apple app store (developer account), so I think I might be loosing money going that way. Anyway, I was testing my game for the web first and everything was working fine. I tested on the iPad after and that is when things started to get hairy.

Yeah, an iPad (iPad 2) is not a full fledged computer (funny to say this considering my first computer was a 486), so it is not as fast. Well I have seen some pretty crazy shit on the iPad, like the Dead Space game so I guess it can be pretty strong. This only means that the Flash player isn’t that great on it, probably because it doesn’t use the GPU. So as I was testing my game on the iPad, it started out working really great, but as the game went on, more and more objects got drawn onto the screen and that is when the performance started to go down. So I set out to optimize my code.

Object pooling

Object creation in Flash is an operation that is costly and since I hadn’t optimized anything yet, I was recreating every object on the screen every frame. There is a possibility of having 240 objects on the screen at the same time, so that’s a lot of object creating every frame. To minimize this, you can do object pooling, which is having a pool of already created objects and change their properties instead of creating new ones. I did just that and it went really fast to implement. The thing is, when I tested it on the iPad, it made no difference at all.

Blitting

Another thing that is heavy on the CPU in Flash is updating graphics, so I tried to optimize that part. Blitting is a technique by which you compress all your visual into only one Bitmap that you draw on the screen. So instead of having multiple display objects being redrawn (in my case 240), you only have one. Read more about blitting here. Blitting doesn’t fit well with every project (like those relying on vector graphics) , but mine was based on Bitmaps and didn’t have a lot of rotations (it did, but only 90 degrees one) so I could easily do it. I was pretty sure that this would help a lot, but it actually did nothing noticeable. I was a bit baffled here, maybe my redrawn zone is too big… It is a game for iPad so I have a full resolution of 1024 x 768, maybe that is too heavy for the Flash Player.

Code Optimization

So if it wasn’t the creation of objects or the graphics, than maybe it was the code. I had used Arrays everywhere cause it is just simpler to use than Vectors, so I changed them all. I also did some loop optimization and replaced some divisions by multiplications ( like /2 to *0.5). Also didn’t change anything…

Last Resort

My last resort was to change the game dynamics so that the game is less intensive on the CPU and that is the only thing that made any impact on performance. My game is a puzzle, so I removed 3 rows and 1 column from it thus reducing the possible maximum number of object on the screen (and also the redrawn region size, and probably also the number of computations) by 20%.

Conclusions

I’m pretty sad at this point, changing the game dynamics to optimize is not a really good decision, it’s kinda like saying let’s make the game less fun to make it run faster. What I liked about Flash is that I could compile for the web, iOs and Android with limited changes (in this case all I changed was different layouts based on size (height and width) of the game). Turns out it is not fast enough on iOs (iPad). Maybe when they put Stage3D on iOs that will do it, but till than there is no true cross development platform. I meant to look into Corona, but it does only mobile. And I really don’t want to fall into the HTML5 mess. I would really like to hear about a dev story about HTML5 and a game built for web and mobile and most importantly how much time it took to do.

, , , , , , , , , , , ,

7 Comments


Workin and playin

I have been working, on my projects and on paid work, and it’s been good. My own project is moving along fine and I should have something new to show pretty soon. As for work, well it’s going. I haven’t got much to write about, what about is mostly some little quirks inside of Flash Professional itself.

But I want to write about this little game I found: The binding of Isaac. I am pretty sure it was made in Flash and a demo of it can be found on Newgrounds. It’s a pretty well done game and it reminds me of the dungeons in Zelda and Kid Icarus. It’s got that same feeling, with upgraded graphics. The lore is also pretty funny, it’s got a really skewed sense of humor but everything fits and I find it very funny. Now the concept is really simple, but because they created so many power ups (each with their own hilarious visual) it makes it so that every run of the dungeon is different and it adds a lot of replayability.  Anyway, that is the kinda game I aspire to make. I advise you to go buy it on Steam, it’s only 5$.

, , , , ,

2 Comments


Porting a game in ActionScript 2 to ActionScript 3

Yesterday I blogged about a post on Emanuele Feronato’s blog. Today he put on is blog some code on an artillery game. It is nice code, but it is in ActionScript 2. I thought it would be fun to try to make the same thing in ActionScript 3. Here is the code from is post

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Mouse.hide();
gravity = 2;
attachMovie("crosshair", "crosshair", 1);
attachMovie("tank", "tank", 2, {_x:230, _y:350});
crosshair.onEnterFrame = function() {
  this._x = _xmouse;
  this._y = _ymouse;
};
tank.onEnterFrame = function() {
  mousex = _xmouse-this._x;
  mousey = (_ymouse-this._y)*-1;
  angle = Math.atan(mousey/mousex)/(Math.PI/180);
  if (mousex<0) {
    angle += 180;
  }
  if (mousex>=0 && mousey>0) {
    angle += 360;
  }
  if (angle<160) {
    angle = 160;
  }
  if (angle<20) {
    angle = 20;
  }
  firepower = Math.sqrt(mousex*mousex+mousey*mousey);
  if (firepower>200) {
    firepower = 200;
  }
  this.cannon._rotation = angle*-1;
};
function onMouseDown() {
  angle = tank.cannon._rotation-1;
  start_ball_x = tank._x+48*Math.cos(angle*Math.PI/180);
  start_ball_y = tank._y+48*Math.sin(angle*Math.PI/180);
  cannonball_fired = attachMovie("cannonball", "cannonball_"+_root.getNextHighestDepth(), _root.getNextHighestDepth(), {_x:start_ball_x, _y:start_ball_y});
  cannonball_fired.dirx = Math.cos(angle*Math.PI/180)*firepower;
  cannonball_fired.diry = Math.sin(angle*Math.PI/180)*firepower;
  cannonball_fired.onEnterFrame = function() {
    this.diry += gravity;
    this._x += this.dirx/50;
    this._y += this.diry/50;
    if (this._y+this._height/2>350) {
      this._y = 350-this._height/2;
      this.diry = -this.diry*.3;
    }
  };
}

This code is on the first frame of the fla file. To transfer this in ActionScript 3 and in an object oriented way (I am just starting to learn object oriented programming so if you see way I could improve the code just tell me so). In order to do so I divided his code into 4 classes. One class for the document class, one class for the crosshair (I don’t think I needed to make this as a class but it seemed like a good way to divide things), one class for the tank and one class for the cannonball. Here is the code for the document class saved in a file called artillery9AS3.as since my fla is named artillery9AS3.fla:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
 
package{
  import flash.display.Sprite;
  import flash.ui.Mouse;
  import flash.events.*;
  import artillery.*;
  public class artillery9AS3 extends Sprite{
    private var gravity:int;
    private var firepower:Number;
    var crosshair:Crosshair;
    var tank:Tank;
    public function artillery9AS3(){
      Mouse.hide();
      gravity = 2;
      crosshair = new Crosshair();
      addChild(crosshair);
      tank = new Tank(230, 350);
      addChild (tank);
      stage.addEventListener(Event.ENTER_FRAME, doEnterFrame);
      stage.addEventListener(MouseEvent.MOUSE_DOWN, doMouseDown);
    }
    private function doEnterFrame(e:Event){
      crosshair.setPos(mouseX, mouseY);
      var newMousex:Number = mouseX-tank.x;
      var newMousey:Number = (mouseY-tank.y)*-1;
      var newAngle:Number = Math.atan(newMousey/newMousex)/(Math.PI/180);
      if (newMousex<0) {
         newAngle += 180;
      }
      if (newMousex>=0 && newMousey>0) {
        newAngle += 360;
      }
      if (newAngle>160) {
         newAngle = 160;
      }
      if (newAngle<20) {
        newAngle = 20;
      }
      tank.setAngle(newAngle);
      firepower = Math.sqrt(newMousex*newMousex+newMousey*newMousey);
      if (firepower>200) {
        firepower = 200;
      }
    }
    private function doMouseDown(e:MouseEvent){
      var angle:Number = tank.getAngle() - 1;
      var start_ball_x:Number = tank.x + 48*Math.cos(angle*Math.PI/180);
      var start_ball_y:Number = tank.y + 48*Math.sin(angle*Math.PI/180);
      var dirX:Number = Math.cos(angle*Math.PI/180)*firepower;
      var dirY:Number = Math.sin(angle*Math.PI/180)*firepower;
      addChild(new Cannonball(start_ball_x, start_ball_y, dirX, dirY, gravity));
    }
  }
}

Mostly what I am doing here is three things, I create the tank and the crosshair, I add the ENTER_FRAME and the MOUSE_DOWN listeners and I handle these events. In the ENTER_FRAME handler I give the new position to the crosshair, and the new angle to the tank. In the MOUSE_DOWN handler, I create a new cannonball and I give it its parameters so that it can update itself alone.

The code for the crosshair and the tank is pretty straight forward so I won’t paste it here, but download the zip file if you want to see it.

Here is the code for the cannonball

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 
package artillery{
  import flash.display.Sprite;
  import flash.events.*;
  public class Cannonball extends Sprite{
  private var dirX:Number;
  private var dirY:Number;
  private var gravity:Number;
  public function Cannonball(xpos:Number, ypos:Number, newDirX:Number, newDirY:Number, newGravity:Number){
    x = xpos;
    y = ypos;
    dirX = newDirX;
    dirY = newDirY;
    gravity = newGravity;
    addEventListener(Event.ENTER_FRAME, doEnterFrame);
  }
  private function doEnterFrame(e:Event):void{
    dirY += gravity;
    x += dirX/50;
    y += dirY/50;
    if (y+ height/2 >350) {
      y = 350- height/2;
      dirY = - dirY * .3;
    }
    if (x < 0)
    {
       removeEventListener(Event.ENTER_FRAME, doEnterFrame);
       this.parent.removeChild(this);
    }
    }
  }
}

This code is saved in a file named Cannonball.as in the folder artillery. Basically it updates its position based on the direction it had was it was created. I modified one thing in this code. When the cannonball x position is less than, I remove the ENTER_FRAME listener and I remove this cannonball from the display list. I do this because, for one the cannonball is not visible anymore so we should not calculate its position. Also, with the previous code, all the cannonballs that you had shot would continue to use up memory, so if you played for a long time, you would eventually run out of memory. By removing the listener and the display object, the garbage collector will remove the unused cannonballs thereby freeing memory.

Also, I mostly used Sprites since there was no timelines involved (the cannon is still a MovieClip, I didn’t take the time to convert it). This is good for the crosshair and the tank, but I think the cannonballs should have stayed a MovieClips since eventually you will want these cannonballs to explode and use a timeline in order to animate the explosions.

Well that is about it for now, feel free to download the files to look at the source code.

Source of the artillery game

, ,

2 Comments


Games, Flash and money

This guy blogs about how to monetize a game you made in flash and what type of game you should target. It’s a nice article, the guy even made a game to experiment with and the game is pretty fun and really simple. I always wanted to make flash games and I have ideas that have been in my head for years but I never took the time to sit down and do them. Also it got me thinking about Air and flash games, now that you can make a desktop version of your game without too much trouble, it gives you another way to monetize your gave by making a small version online and a big version for the desktop.

, ,

No Comments