Skip to content
Browse files

Face for the paddle

  • Loading branch information...
1 parent eedb4e0 commit ed1669f8377f1491d5eb7550416b8e954449f2aa @grapefrukt committed May 22, 2012
View
3 .gitignore
@@ -1,2 +1,3 @@
bin/
-obj/
+obj/
+*.swf
View
BIN assets/juicy-face.fla
Binary file not shown.
View
BIN assets/juicy-face.swc
Binary file not shown.
View
2 juicy-breakout.as3proj
@@ -52,7 +52,7 @@
</includeLibraries>
<!-- SWC Libraries -->
<libraryPaths>
- <!-- example: <element path="..." /> -->
+ <element path="assets\juicy-face.swc" />
</libraryPaths>
<!-- External Libraries -->
<externalLibraryPaths>
View
6 src/com/grapefrukt/games/juicy/Main.as
@@ -137,6 +137,8 @@ package com.grapefrukt.games.juicy {
_lines.update(_timestep.timeDelta);
_screenshake.update(_timestep.timeDelta);
+ _paddle.lookAt(Ball(_balls.collection[0]));
+
if (Settings.EFFECT_PADDLE_STRETCH) {
_paddle.scaleX = 1 + Math.abs(_paddle.x - mouseX) / 100;
_paddle.scaleY = 1.5 - _paddle.scaleX * .5;
@@ -279,6 +281,10 @@ package com.grapefrukt.games.juicy {
if (e.keyCode == Keyboard.S) _screenshake.shakeRandom(4);
if (e.keyCode == Keyboard.NUMBER_1) _toggler.setAll(true);
if (e.keyCode == Keyboard.NUMBER_2) _toggler.setAll(false);
+ if (e.keyCode == Keyboard.P) {
+ var b:Ball = _balls.collection[0] as Ball;
+ ParticleSpawn.burst(b.x, b.y, 10, 360, Math.atan2(b.velocityY, b.velocityX) * 180 / Math.PI, 100, .1, _particles_impact);
+ }
}
private function handleMouseToggle(e:MouseEvent):void {
View
10 src/com/grapefrukt/games/juicy/Settings.as
@@ -46,6 +46,10 @@ package com.grapefrukt.games.juicy {
static public var EFFECT_BALL_TRAIL_SCALE :Boolean = false;
static public var EFFECT_PADDLE_STRETCH :Boolean = false;
+ static public var EFFECT_PADDLE_FACE :Boolean = false;
+ [min("1")] [max("100")]
+ static public var EFFECT_PADDLE_SMILE :int = 1;
+ static public var EFFECT_PADDLE_LOOK_AT_BALL :Boolean = false;
static public var EFFECT_PARTICLE_BALL_COLLISION :Boolean = true;
static public var EFFECT_PARTICLE_BLOCK_SHATTER :Boolean = true;
@@ -61,7 +65,7 @@ package com.grapefrukt.games.juicy {
static public var POWERUP_SLICER_BALL :Boolean = false;
- static public var SOUNDS :Boolean = false;
+ static public var SOUNDS :Boolean = true;
static public const NUM_BALLS :uint = 1;
static public const BALL_MAX_VELOCITY :Number = 5;
@@ -73,8 +77,8 @@ package com.grapefrukt.games.juicy {
static public const COLOR_BACKGROUND :uint = 0x490a3d;
static public const COLOR_BLOCK :uint = 0xbd1550;
- static public const COLOR_BALL :uint = 0xe97f02;
- static public const COLOR_PADDLE :uint = 0xf8ca00;
+ static public const COLOR_BALL :uint = 0xf8ca00;
+ static public const COLOR_PADDLE :uint = 0xe97f02;
static public const COLOR_TRAIL :uint = 0x8a9b0f;
static public const COLOR_SPARK :uint = 0xffffff;
static public const COLOR_BOUNCY_LINES :uint = 0xbd1550;
View
5 src/com/grapefrukt/games/juicy/gameobjects/Block.as
@@ -11,6 +11,7 @@ package com.grapefrukt.games.juicy.gameobjects {
import com.gskinner.motion.GTween;
import com.gskinner.motion.plugins.ColorTransformPlugin;
import flash.display.Shape;
+ import flash.display.Sprite;
import flash.events.Event;
import flash.events.TimerEvent;
import flash.geom.ColorTransform;
@@ -27,15 +28,15 @@ package com.grapefrukt.games.juicy.gameobjects {
protected var _collisionH:Number = Settings.BLOCK_H;
protected var _collidable:Boolean = true;
- protected var _gfx:Shape;
+ protected var _gfx:Sprite;
private var _sliceEffect:SliceEffect;
public function Block(x:Number, y:Number) {
this.x = x;
this.y = y;
- _gfx = new Shape();
+ _gfx = new Sprite;
addChild(_gfx);
render(Settings.COLOR_BLOCK);
View
20 src/com/grapefrukt/games/juicy/gameobjects/Paddle.as
@@ -7,11 +7,16 @@ package com.grapefrukt.games.juicy.gameobjects {
*/
public class Paddle extends Block {
+ private var _face:PaddleFace;
+
public function Paddle() {
super(Settings.STAGE_W / 2, Settings.STAGE_H + Settings.PADDLE_H / 2 - 50);
_collisionW = Settings.PADDLE_W;
_collisionH = Settings.PADDLE_H;
render(Settings.COLOR_PADDLE);
+
+ _face = new PaddleFace();
+ _gfx.addChild(_face);
}
override public function collide(ball:Ball):void {
@@ -20,6 +25,21 @@ package com.grapefrukt.games.juicy.gameobjects {
override public function update(timeDelta:Number = 1):void {
super.update(timeDelta);
+ _face.visible = Settings.EFFECT_PADDLE_FACE;
+ _face.mouth.gotoAndStop(Settings.EFFECT_PADDLE_SMILE);
+ }
+
+ public function lookAt(ball:Ball):void {
+ if (Settings.EFFECT_PADDLE_LOOK_AT_BALL) {
+ _face.eye_l.rotation = -Math.atan2(
+ this.x + _face.eye_l.x - ball.x,
+ this.y + _face.eye_l.y - ball.y) * 180 / Math.PI;
+ _face.eye_r.rotation = -Math.atan2(
+ this.x + _face.eye_r.x - ball.x,
+ this.y + _face.eye_r.y - ball.y) * 180 / Math.PI;
+ } else {
+ _face.eye_l.rotation = _face.eye_r.rotation = 0;
+ }
}
override protected function render(color:uint):void {

0 comments on commit ed1669f

Please sign in to comment.
Something went wrong with that request. Please try again.