Skip to content

Commit

Permalink
#2 adding level 2 paddle animation
Browse files Browse the repository at this point in the history
  • Loading branch information
myselfhimself committed Jun 3, 2021
1 parent b254232 commit 006f6b3
Show file tree
Hide file tree
Showing 16 changed files with 35 additions and 9 deletions.
44 changes: 35 additions & 9 deletions level.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@
//mouse to control the paddle, click to start
BWB_DEBUG = false;

// Sprites
var paddle, ball, wallTop, wallBottom, wallLeft, wallRight;
var bricks;

// Level-3 related
var cog1; // cog image
var cog2; // cog image
var cog3; // cog image
var cogs; // list of cog images
var cogs_interspacing_width_ratio = 0.8;


var LEVELS_DATA = [
// Level 1
{
Expand All @@ -18,6 +24,14 @@ var LEVELS_DATA = [
soundtrack_volume: 1.0,
ball_start_x: function(){return width / 2;},
ball_start_y: function(){return height - 350;},
paddle: {
setup: function() {
paddle = createSprite(PADDLE_START_POSITION_X, PADDLE_START_POSITION_Y, PADDLE_W, PADDLE_H);
paddle.addAnimation('live', 'sprites/food/level1/paddle/paddle-001.png', 'sprites/food/level1/paddle/paddle-004.png');
paddle.setCollider('rectangle');
}
},

ball: {
setup: function() {
ball = createSprite(BALL_START_POSITION_X(), BALL_START_POSITION_Y(), BALL_DIAMETER, BALL_DIAMETER);
Expand Down Expand Up @@ -91,6 +105,14 @@ var LEVELS_DATA = [
background: 'sprites/food/level2/background/lehavre_background.png',
soundtrack: null,
soundtrack_volume: 1.0,
paddle: {
setup: function() {
paddle = createSprite(PADDLE_START_POSITION_X, PADDLE_START_POSITION_Y, PADDLE_W, PADDLE_H);
paddle.addAnimation('live', 'sprites/food/level2/paddle/paddle0.png', 'sprites/food/level2/paddle/paddle4.png');
paddle.setCollider('rectangle');
}
},

ball: {
setup: function() {
ball = createSprite(BALL_START_POSITION_X(), BALL_START_POSITION_Y(), BALL_DIAMETER, BALL_DIAMETER);
Expand Down Expand Up @@ -133,6 +155,7 @@ var LEVELS_DATA = [
// TODO ball setup() and draw()
ball: {setup: null},
// TODO paddle setup() and draw()
paddle: {setup: null},
bricks: {
count: 10,
width: 20,
Expand Down Expand Up @@ -170,10 +193,6 @@ var LEVELS_DATA = [
}
];

// Sprites
var paddle, ball, wallTop, wallBottom, wallLeft, wallRight;
var bricks;

// Sound
var brickExplodeSound;
var paddleHitSound;
Expand All @@ -182,6 +201,10 @@ var bottomHitSound;
var soundtrack;

// Game constants
var PADDLE_W = 146;
var PADDLE_H = 10;
var PADDLE_START_POSITION_X = BWB_WIDTH / 2;
var PADDLE_START_POSITION_Y = BWB_HEIGHT-11;
var BALL_DIAMETER = 30;
var BALL_START_POSITION_X = function () { return LEVELS_DATA[BWB_LEVEL_ID].ball_start_x != undefined ? LEVELS_DATA[BWB_LEVEL_ID].ball_start_x() : width / 2;};
var BALL_START_POSITION_Y = function () { return LEVELS_DATA[BWB_LEVEL_ID].ball_start_y != undefined ? LEVELS_DATA[BWB_LEVEL_ID].ball_start_y() : height - 200;};
Expand Down Expand Up @@ -215,11 +238,14 @@ function preload() {
function setup() {
setupCanvas(false);

paddle = createSprite(width / 2, height-11, 110, 46);
console.log("paddle loading start");
paddle.addAnimation('live', 'sprites/food/level1/paddle/paddle-001.png', 'sprites/food/level1/paddle/paddle-004.png');
console.log("paddle loading end");
paddle.setCollider('rectangle');

if(LEVELS_DATA[BWB_LEVEL_ID].paddle.setup != null) {
LEVELS_DATA[BWB_LEVEL_ID].paddle.setup();
} else {
paddle = createSprite(PADDLE_START_POSITION_X, PADDLE_START_POSITION_Y, PADDLE_W, PADDLE_H);
paddle.addAnimation('live', 'sprites/food/level1/paddle/paddle-001.png', 'sprites/food/level1/paddle/paddle-004.png');
paddle.setCollider('rectangle');
}
paddle.debug = BWB_DEBUG;
paddle.immovable = true;

Expand Down
Binary file added sprites/food/level2/paddle/0034/big_paddle0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sprites/food/level2/paddle/0034/big_paddle1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sprites/food/level2/paddle/0034/big_paddle2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sprites/food/level2/paddle/0034/big_paddle3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sprites/food/level2/paddle/0034/big_paddle4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sprites/food/level2/paddle/paddle0.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sprites/food/level2/paddle/paddle0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sprites/food/level2/paddle/paddle1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sprites/food/level2/paddle/paddle1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sprites/food/level2/paddle/paddle2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sprites/food/level2/paddle/paddle2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sprites/food/level2/paddle/paddle3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sprites/food/level2/paddle/paddle3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sprites/food/level2/paddle/paddle4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sprites/food/level2/paddle/paddle4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 006f6b3

Please sign in to comment.