User prompt
change the system for guard & guard button: keep athlete in guard state when button is down, restore when button is up
User prompt
in guard() funciton, move the hands ,forearms and hands closer to the center of the torso then restore them when button is released
User prompt
in guard() funciton, move the hands ,forearms and hands closer to the center of the torso
Code edit (19 edits merged)
Please save this source code
User prompt
implement the athlete guard action
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
use the Ring class in gameInitialize
User prompt
create a Class for the ring
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: player is undefined' in or related to this line: 'if ((player.leftHand.intersects(opponent.head) || player.rightHand.intersects(opponent.head)) && player.isPunching) {' Line Number: 293
Code edit (1 edits merged)
Please save this source code
User prompt
only flash on hit when an athlete is Punching
User prompt
restore self.isPunching
User prompt
update self.isPunching
User prompt
add a propoery isPunching to athlete class
Code edit (1 edits merged)
Please save this source code
User prompt
set isPlaying to true on 1st screen tap
Code edit (1 edits merged)
Please save this source code
User prompt
don't update athletes when isPlaying is false
Code edit (2 edits merged)
Please save this source code
User prompt
add a globalVariable isPlaying
Code edit (1 edits merged)
Please save this source code
User prompt
in mainMove(); define a target within the ring then progressively move to the target. when reached choose another target
===================================================================
--- original.js
+++ change.js
@@ -20,16 +20,16 @@
y: -125,
width: 80,
rotation: -Math.PI * 0.2
});
- self.leftHand = self.body.attachAsset('hand', {
+ self.leftHand = self.body.attachAsset(isPlayer ? 'hand' : 'hand2', {
anchorX: 0.5,
anchorY: 0.5,
x: -110,
y: -250,
width: 80,
height: 180,
- rotation: -Math.PI * 0.05
+ rotation: isPlayer ? -Math.PI * 0.05 : -Math.PI * 0.2
});
self.leftArm = self.body.attachAsset('arm', {
anchorX: 0.5,
anchorY: 0,
@@ -45,17 +45,17 @@
scaleX: -1,
width: 80,
rotation: Math.PI * 0.2
});
- self.rightHand = self.body.attachAsset('hand', {
+ self.rightHand = self.body.attachAsset(isPlayer ? 'hand' : 'hand2', {
anchorX: 0.5,
anchorY: 0.5,
x: 110,
y: -250,
scaleX: -1,
width: 80,
height: 180,
- rotation: Math.PI * 0.05
+ rotation: isPlayer ? Math.PI * 0.05 : Math.PI * 0.15
});
self.rightArm = self.body.attachAsset('arm', {
anchorX: 0.5,
anchorY: 0,
@@ -170,10 +170,10 @@
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.8
});
- self.x = game.width / 2; // Position button in the bottom center
- self.y = game.height - 220;
+ self.x = 400; // Position button in the bottom center
+ self.y = game.height - 350;
self.down = function (x, y, obj) {
// Simulate guard button press
self.alpha = 0.5; // Dim the button to indicate it's pressed
};
@@ -191,10 +191,10 @@
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.8
});
- self.x = game.width - 220; // Position button on the bottom right
- self.y = game.height - 220;
+ self.x = game.width - 400; // Position button on the bottom right
+ self.y = game.height - 350;
self.down = function (x, y, obj) {
// Simulate button press by triggering punch with left arm
player.punch(Math.random() < 0.5); // Randomly choose left or right arm for punching
self.width *= 0.9;
@@ -205,16 +205,19 @@
self.width /= 0.9;
self.height /= 0.9;
};
});
+/****************************************************************************************** */
+/**************************************** RING CLASS ************************************** */
+/****************************************************************************************** */
var Ring = Container.expand(function () {
var self = Container.call(this);
self.ringAsset = self.attachAsset('ring', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = 1024; // Center of the screen horizontally
- self.y = 1366; // Center of the screen vertically
+ self.y = 1366 - self.height / 6; // Center of the screen vertically
});
/****
* Initialize Game
@@ -225,8 +228,11 @@
/****
* Game Code
****/
+/****************************************************************************************** */
+/************************************** GLOBAL VARIABLES ********************************** */
+/****************************************************************************************** */
var isPlaying = false;
var ring;
var punchButton;
var guardButton;
@@ -255,11 +261,10 @@
};
game.move = function (x, y, obj) {};
game.up = function (x, y, obj) {};
/****************************************************************************************** */
-/************************************* GAME STATES **************************************** */
+/************************************ GAME INITIALIZE ************************************* */
/****************************************************************************************** */
-// GAME INITIALIZE
function gameInitialize() {
log("Game initialize...");
// Initialize Ring
ring = game.addChild(new Ring());
@@ -267,13 +272,13 @@
guardButton = game.addChild(new GuardButton());
// Initialize Player
player = game.addChild(new Athlete(true));
player.x = 1024; // Center horizontally
- player.y = game.height * 0.7; // Position towards the bottom
+ player.y = game.height * 0.6; // Position towards the bottom
// Initialize Opponent
opponent = game.addChild(new Athlete());
opponent.x = 1024; // Center horizontally
- opponent.y = 1066; // Center vertically in the middle of the ring
+ opponent.y = game.height * 0.2; // Center vertically in the middle of the ring
opponent.rotation = Math.PI * 0.5;
}
/****************************************************************************************** */
/************************************** MAIN GAME LOOP ************************************ */
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..