Game prototype involving shape drawing and a ball
Sometimes I play and mess with code to get some interesting game prototypes.
Although I am not satisfied about this one, I want to share it with you anyway.
You have to draw a lasso with the mouse trying to catch the ball inside the shape you will create. In this case you'll win.
If the ball touches the line before you close the shape, you die.
Uncommented code because it's just an early stage, but if you are interested I will try to turn it into something playable.
-
drawing = false;
-
angle = Math.random()*360;
-
speed = 5;
-
precision = 16;
-
xspeed = speed*Math.cos(angle*0.0174532925);
-
yspeed = speed*Math.sin(angle*0.0174532925);
-
_root.createEmptyMovieClip("drawclip", 1);
-
_root.attachMovie("ball", "ball", 2, {_x:250, _y:200});
-
_root.onMouseDown = function() {
-
x_points = new Array();
-
y_points = new Array();
-
drawing = true;
-
drawclip.clear();
-
still_inside = true;
-
drawclip.lineStyle(5, 0x000000);
-
x_points.push(_root._xmouse);
-
y_points.push(_root._ymouse);
-
drawclip.moveTo(x_points[0], y_points[0]);
-
};
-
_root.onMouseUp = function() {
-
drawing = false;
-
};
-
_root.onMouseMove = function() {
-
if (drawing) {
-
end_x = _root._xmouse;
-
end_y = _root._ymouse;
-
dist_x = x_points[0]-end_x;
-
dist_y = y_points[0]-end_y;
-
dist = dist_x*dist_x+dist_y*dist_y;
-
if (dist>400) {
-
still_inside = false;
-
drawclip.lineTo(end_x, end_y);
-
x_points.push(end_x);
-
y_points.push(end_y);
-
} else {
-
if (still_inside) {
-
drawclip.lineTo(end_x, end_y);
-
x_points.push(end_x);
-
y_points.push(end_y);
-
} else {
-
x_points.push(x_points[0]);
-
y_points.push(y_points[0]);
-
drawclip.lineTo(x_points[0], y_points[0]);
-
drawing = false;
-
drawclip.clear();
-
drawclip.lineStyle(5, 0x00ff00);
-
drawclip.beginFill(0x00ff00, 30);
-
drawclip.moveTo(x_points[0], y_points[0]);
-
for (x=1; x<x_points.length; x++) {
-
drawclip.lineTo(x_points[x], y_points[x]);
-
}
-
if (drawclip.hitTest(ball._x, ball._y, true)) {
-
ball._x = 250;
-
ball._y = 200;
-
}
-
}
-
}
-
}
-
};
-
ball.onEnterFrame = function() {
-
this._x += xspeed;
-
this._y += yspeed;
-
if ((this._x<10) or (this._x>490)) {
-
xspeed *= -1;
-
}
-
if ((this._y<10) or (this._y>390)) {
-
yspeed *= -1;
-
}
-
};
-
_root.onEnterFrame = function() {
-
if (drawing) {
-
for (x=1; x<precision; x++) {
-
spot_x = ball._x+10*Math.sin(x*360/precision*0.0174532925);
-
spot_y = ball._y+10*Math.cos(x*360/precision*0.0174532925);
-
if (drawclip.hitTest(spot_x, spot_y, true)) {
-
drawing = false;
-
drawclip.clear();
-
break;
-
}
-
}
-
}
-
};
and enjoy the result...
When you "die", you just lose your drawing. When the ball dies, it simply respawns at the centre of the stage.
They can be easily customized to meet the unique requirements of your project.
9 Responses to “Game prototype involving shape drawing and a ball”
Leave a Reply
Trackbacks
-
Flash tutorials | Drawing with AS3 | Lemlinh.com on
August 30th, 2008 1:15 pm
[...] Read more [...]
Posts
- Rick Triqui: my first PlayCrafter game
- Prototype of a Flash game like Meeblings
- Games for the game developers!
- The art of debugging
- How to embed a text file in Flash
- Create a Flash game in minutes with PlayCrafter
- Upgrade your Flash CS4 to 10.0.2
- Play Mazeroll, my latest Box2D game
- Triqui MochiAds Arcade plugin for WordPress Released!!
- The MochiAds funnel
- Flash game creation tutorial - part 1
- Create a Lightbox effect only with CSS - no javascript needed
- Flash game creation tutorial - part 2
- Make a Flash game like Flash Element Tower Defense - Part 2
- Flash game creation tutorial - part 3
- Create a flash draw game like Line Rider or others - part 1
- Create a Flash Racing Game Tutorial
- Make a Flash game like Flash Element Tower Defense - Part 1
- Create a flash artillery game - step 1
- Create a flash draw game like Line Rider or others - part 5
- Flash game creation tutorial – part 5.2




(4.9 out of 5) - Flash game creation tutorial – part 3




(4.86 out of 5) - Creation of a platform game with Flash – step 2




(4.84 out of 5) - Create a survival horror game in Flash tutorial – part 1




(4.82 out of 5) - Create a flash artillery game – step 1




(4.82 out of 5) - Create a Flash Racing Game Tutorial




(4.8 out of 5) - Create a flash artillery game – step 2




(4.75 out of 5) - New tile based platform engine – part 6 – ladders




(4.74 out of 5) - Flash game creation tutorial – part 2




(4.73 out of 5) - The experiment – one year later




(4.7 out of 5)
(10 votes, average: 4 out of 5)

It’s interesting though doesn’t really work properly. Would be interesting to see it ‘themed’ so maybe instead of a ball it’s an insect you have to catch.
Very nice idea. I’d like to see a real game come out of it.
nice!
The ball keeps getting suck on the edges.
I’ve already seen something really really similar on FlashGameLicense.com a few days ago.
Not a bad prototype. This sort of game is really well done here:
http://www.bigfooty.com.au/rules/
Hey! Thats like my game! I released it on FGL two weeks ago.
Weird. Anyway, good tutorial.
Check out “wires” on FGL. Its exactly like this.
Oh, Marco’s already seen it.