Code edit (8 edits merged)
Please save this source code
User prompt
in guard(), also add a deltaY to adjustments array
User prompt
add deltaY to the adjustments
User prompt
in guard(), also add a deltaY
Code edit (1 edits merged)
Please save this source code
User prompt
in adjustPosition(), simplify by making direction depend on setGuard also
User prompt
in adjustPosition(), simplify by defining a direction variable that depends on index and setGuard
User prompt
in guard, also Invert deltaR for the second element
User prompt
in gard(), simplify the adjustments as they are symetrical. use an array for elements
User prompt
now in guard(), add adjustments for arms too
User prompt
now refactor the gard() function
User prompt
in guar(), use the deltas in the else block
Code edit (18 edits merged)
Please save this source code
User prompt
simplify guard() function bt defining local variables for the deltas (like handXDelta, handRDelta, forearmXDelta, ....)
Code edit (1 edits merged)
Please save this source code
User prompt
in guard() function, move the hands ,forearms and hands closer to the center of the torso then restore them when leaving guard state the system for guard & guard button: set & keep athlete in guard state when button is down, restore when button is up
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
===================================================================
--- 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..