Code edit (2 edits merged)
Please save this source code
User prompt
when punching, also change the width of the head to simulate the tilt
Code edit (2 edits merged)
Please save this source code
User prompt
when punching, move of the head like boxers do
User prompt
prevent players to be too close
User prompt
add a bit of randomness to the mini movements
Code edit (1 edits merged)
Please save this source code
User prompt
when idmle, animate the players with mini movements of head and arms
User prompt
when punching, randomly choose left or right arm
Code edit (5 edits merged)
Please save this source code
User prompt
in player update, also compute the angleToOpponent for the enemy
Code edit (3 edits merged)
Please save this source code
User prompt
when player moves, update its rotatoin to always face the opponent
Code edit (1 edits merged)
Please save this source code
Code edit (5 edits merged)
Please save this source code
User prompt
add a new button at bottom right for punch
Code edit (5 edits merged)
Please save this source code
User prompt
only move the human player with joystick
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: base is not defined' in or related to this line: 'var dx = localPos.x - base.x;' Line Number: 34
User prompt
Please fix the bug: 'ReferenceError: base is not defined' in or related to this line: 'var maxDistance = base.width / 2; // Max distance knob can move from center' Line Number: 31
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: joystick.knob is undefined' in or related to this line: 'var joystickDx = joystick.knob.x;' Line Number: 188
User prompt
make the player move using the joystick
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -5,20 +5,20 @@
var self = Container.call(this);
self.base = self.attachAsset('joystickBase', {
anchorX: 0.5,
anchorY: 0.5,
- alpha: 0.75
+ alpha: 0.7
});
self.knob = self.attachAsset('joystickKnob', {
anchorX: 0.5,
anchorY: 0.5,
- alpha: 0.75
+ alpha: 0.9
});
self.x = 220; // Position joystick on the bottom left
self.y = game.height - 220;
var dragging = false;
var dragStart = null;
- var maxDistance = self.base.width / 2; // Max distance knob can move from center
+ var maxDistance = self.base.width / 2 - self.knob.width / 2; // Max distance knob can move from center
self.down = function (x, y, obj) {
var localPos = self.toLocal(obj.global);
var dx = localPos.x - self.base.x;
var dy = localPos.y - self.base.y;
@@ -193,8 +193,20 @@
self.body.y = self.y;
self.body.rotation = self.rotation;
};
});
+var PunchButton = Container.expand(function () {
+ var self = Container.call(this);
+ var buttonGraphics = self.attachAsset('punchButton', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.x = game.width - 150; // Position button on the bottom right
+ self.y = game.height - 100;
+ self.down = function (x, y, obj) {
+ player.punch(true); // Trigger punch action for the player
+ };
+});
/****
* Initialize Game
****/
@@ -204,15 +216,9 @@
/****
* Game Code
****/
-// Initialize and add joystick to the game
-// Initialize and add joystick to the game
-var joystick;
-game.addChild(function () {
- joystick = new Joystick();
- return joystick;
-}());
+var punchButton = game.addChild(new PunchButton());
// Initialize ring in the game scene
var ring = game.addChild(LK.getAsset('ring', {
x: 1024,
// Center horizontally
@@ -220,8 +226,9 @@
// Center vertically
anchorX: 0.5,
anchorY: 0.5
}));
+var joystick = game.addChild(new Joystick());
var dragNode = null;
// Initialize player
var player = game.addChild(new Player(true));
player.x = 1024; // Center horizontally
clear
basic light gray convex round button with a red boxing glove icon. UI
Un gant de boxe bleu vu de dessus. video game
basic light round convex gray button with a raised blue shield icon.. UI
un éclair. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
remove
a basic white heart.. game icon
A boxer has lost the match..
man boxer with red gloves is KO on the ring..