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
@@ -217,39 +217,61 @@
/****
* Game Code
****/
var isPlaying = false;
-// Initialize ring in the game scene
-// TODO : Move to a class
-var ring = game.addChild(LK.getAsset('ring', {
- x: 1024,
- y: 1366,
- anchorX: 0.5,
- anchorY: 0.5
-}));
-var punchButton = game.addChild(new PunchButton());
-var guardButton = game.addChild(new GuardButton());
-// Initialize player
-var player = game.addChild(new Athlete(true));
-player.x = 1024; // Center horizontally
-player.y = 2000; // Position towards the bottom
-// Initialize a single fixed opponent
-var opponent = game.addChild(new Athlete());
-opponent.x = 1024; // Center horizontally
-opponent.y = 1066; // Center vertically in the middle of the ring
-opponent.rotation = Math.PI * 0.5;
-// Update the single fixed enemy
-//opponent.update();
+var ring;
+var punchButton;
+var guardButton;
+var player;
+var opponent;
var touchPosition = null;
var swipeStart = null;
var swipeEnd = null;
+var isDebug = false;
+/****************************************************************************************** */
+/*********************************** UTILITY FUNCTIONS ************************************ */
+/****************************************************************************************** */
+function log() {
+ if (isDebug) {
+ var _console;
+ (_console = console).log.apply(_console, arguments);
+ }
+}
+/****************************************************************************************** */
+/************************************** INPUT HANDLERS ************************************ */
+/****************************************************************************************** */
game.down = function (x, y, obj) {
if (!isPlaying) {
isPlaying = true;
}
};
game.move = function (x, y, obj) {};
game.up = function (x, y, obj) {};
+/****************************************************************************************** */
+/************************************* GAME STATES **************************************** */
+/****************************************************************************************** */
+// GAME INITIALIZE
+function gameInitialize() {
+ log("Game initialize...");
+ // Initialize Ring
+ ring = game.addChild(LK.getAsset('ring', {
+ x: 1024,
+ y: 1366,
+ anchorX: 0.5,
+ anchorY: 0.5
+ }));
+ punchButton = game.addChild(new PunchButton());
+ guardButton = game.addChild(new GuardButton());
+ // Initialize Player
+ player = game.addChild(new Athlete(true));
+ player.x = 1024; // Center horizontally
+ player.y = 2000; // 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.rotation = Math.PI * 0.5;
+}
// Game update function
game.update = function () {
// This section has been removed to prevent redundant player movement handling.
// Check for collision between player's hand and enemy's head
@@ -264,5 +286,6 @@
LK.setTimeout(function () {
opponent.head.y += 20; // Head returns to normal position
}, 500);
}
-};
\ No newline at end of file
+};
+gameInitialize();
\ No newline at end of file
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..