Code edit (6 edits merged)
Please save this source code
User prompt
when Zbert is moving Up right or up left check when zberet is about to jump if a tile is there for Zebert to jump to if not jump and then have zebert fall to bottom of screen
Code edit (11 edits merged)
Please save this source code
User prompt
When Zbert jumps off last tile going up left or up right then run fall rountine
User prompt
When zebert moves up and to right check if tile exists below zbert. if not then run fall routine
Code edit (1 edits merged)
Please save this source code
User prompt
When zbert is jumping ignore additional control kep presses until after tile flip code run
User prompt
When Zbert moves from tile to tile create a smooth upward arc in direction of travel for Zbert
User prompt
Fix Bug: 'ReferenceError: startTime is not defined' in or related to this line: 'if (currentTime - startTime < hopDuration) {' Line Number: 59
User prompt
When Zbert moves from tile to tile animate a little hop
User prompt
When Zbert moves from tile to tile animate a little vertical hop
Code edit (13 edits merged)
Please save this source code
User prompt
when moving Zbert from tile to tile ensure Zbert is aligned to middle of each tile as per the first tile alignment
User prompt
check in zbert jump that the tile to flip is the one below Zbeter
User prompt
When Zbert jumps from Tile to Tile chack if tile he lands on needs to be flipped
User prompt
When Zbert is jumping ensure it is from centre to centre of tiles in the direction he is travelling. Check when he lands if tile is to be flipped and if so then flip tile.
User prompt
when Zbert Jumps make sure Zbert lands on target tile correctly. Check if tile needs to be flipped
User prompt
Change jump arc so opposite to current arc
User prompt
In zbert jump rountine make the jump between two tiles an arc upwards
User prompt
when moving Zbert from tile to tile make Zbert do a little jump as he moves. The jump size and directions linked to direction of movement. Jump to be from centre of tile to centre of tile jumping to
User prompt
When Zbert jumps detect direction Zbert is jumping and make sure jump is from tile to tile
User prompt
When moving Zbert from tile to tile make Zbert do a little jump as he moves
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
in tile set cell Zbert starts on to target colour
===================================================================
--- original.js
+++ change.js
@@ -29,26 +29,26 @@
var self = Container.call(this);
self.move = function (direction) {
var moveX = 0;
var moveY = 0;
- var tileWidth = game.grid.getTileAt(self.x, self.y).width;
- var tileHeight = game.grid.getTileAt(self.x, self.y).height;
+ var tileWidth = 250;
+ var tileHeight = 270;
switch (direction) {
case 'upLeft':
- moveX = -tileWidth;
- moveY = -tileHeight;
+ moveX = -tileWidth / 2;
+ moveY = -tileHeight + 90;
break;
case 'upRight':
- moveX = tileWidth;
- moveY = -tileHeight;
+ moveX = tileWidth / 2;
+ moveY = -tileHeight + 90;
break;
case 'downLeft':
- moveX = -tileWidth;
- moveY = tileHeight;
+ moveX = -tileWidth / 2;
+ moveY = tileHeight - 90;
break;
case 'downRight':
- moveX = tileWidth;
- moveY = tileHeight;
+ moveX = tileWidth / 2;
+ moveY = tileHeight - 90;
break;
}
// Calculate the jump height based on the direction
var jumpHeight = 50;
@@ -58,54 +58,58 @@
// Calculate the peak of the jump based on the direction
var peakX = self.x + moveX / 2;
var peakY = self.y + moveY / 2 - jumpHeight;
// Animate Zbert's jump to the peak
+ var jumpToPeakDuration = 200; // Duration in milliseconds
+ var jumpToPeakStartTime = Date.now();
var jumpDuration = 400; // Total duration of the jump in milliseconds
var jumpStartTime = Date.now();
LK.on('tick', function jumpArc() {
var currentTime = Date.now();
var timeElapsed = currentTime - jumpStartTime;
if (timeElapsed < jumpDuration) {
var jumpProgress = timeElapsed / jumpDuration;
// Calculate the arc using a quadratic function for y based on x
- self.x = peakX + jumpProgress * (endX - peakX);
- var peakProgress = -4 * jumpHeight * (jumpProgress * (jumpProgress - 1));
- self.y = peakY + jumpProgress * (endY - peakY) + peakProgress;
+ self.x = self.x + jumpProgress * (endX - self.x);
+ var peakProgress = 4 * jumpHeight * (jumpProgress * (jumpProgress - 1));
+ self.y = self.y + jumpProgress * (endY - self.y) + peakProgress;
} else {
self.x = endX;
self.y = endY;
LK.off('tick', jumpArc); // Stop the jump arc animation
- // Check for tile flip after landing
+ }
+ });
+ // Detect the tile Zbert is moving to and flip its color
+ LK.on('tick', function checkTile() {
+ var currentTime = Date.now();
+ var timeElapsed = currentTime - jumpStartTime;
+ if (timeElapsed >= jumpDuration) {
var tileBelow = game.grid.getTileAt(self.x, self.y);
if (tileBelow) {
tileBelow.flipColor();
+ } else {
+ // If Zbert is not on a tile, move him back behind the grid
+ self.x = game.grid.x - self.width;
+ self.y = 0;
+ // Animate Zbert falling to the bottom of the screen
+ var fallToY = game.height - self.height / 2;
+ var fallDuration = 4000; // Fall duration in milliseconds
+ var fallStartTime = Date.now();
+ LK.on('tick', function () {
+ var currentTime = Date.now();
+ var timeElapsed = currentTime - fallStartTime;
+ if (timeElapsed < fallDuration) {
+ var fallProgress = timeElapsed / fallDuration;
+ self.y = fallProgress * fallToY;
+ } else {
+ self.y = fallToY;
+ LK.off('tick'); // Stop the fall animation
+ }
+ });
}
+ LK.off('tick', checkTile); // Stop checking for tile after jump is complete
}
});
- // Detect the tile Zbert is moving to and flip its color
- var tileBelow = game.grid.getTileAt(self.x, self.y + tileHeight);
- if (tileBelow) {
- tileBelow.flipColor();
- } else {
- // If Zbert is not on a tile, move him back behind the grid
- self.x = game.grid.x - self.width;
- self.y = 0;
- // Animate Zbert falling to the bottom of the screen
- var fallToY = game.height - self.height / 2;
- var fallDuration = 4000; // Fall duration in milliseconds
- var fallStartTime = Date.now();
- LK.on('tick', function () {
- var currentTime = Date.now();
- var timeElapsed = currentTime - fallStartTime;
- if (timeElapsed < fallDuration) {
- var fallProgress = timeElapsed / fallDuration;
- self.y = fallProgress * fallToY;
- } else {
- self.y = fallToY;
- LK.off('tick'); // Stop the fall animation
- }
- });
- }
};
var zbertGraphics = self.attachAsset('Zbert1', {
anchorX: 0.5,
anchorY: 0.5
beautiful landscape. starry sky, pastel colours, high definition, alien world. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
beautiful landscape. starry sky, pastel colours, high definition, alien world.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
beautiful expansive landscape. starry sky, pastel colours, high definition, alien world.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
beautiful expansive landscape. starry sky, pastel colours, high definition, alien world.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A little cube person. 2 legs. back to viewer. facing 45 degrees to the right. multicoloured skin, cartoon style. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
white circle. metallic. light bevel on edge. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Round furry, cute alien ball with big eyes. vivid colours, looking at 45 degrees to the right. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
bright 3d present with bow, vivd colours. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Change to be vivid multicoloured cube
A simple Triangle, flat shaded, bevelled edges. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Speech bubble with expletive word in it. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
parachute. multicoloured. cartoon style.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
white circle with a single thin black border. flat shade. simple graphic. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
small star shape, vivid metallic blue, varying length spikes on star. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.