User prompt
there are cases where all tracks are blocked by an obstacle at the same time, please fix this
User prompt
Make obstacles spawn more rarely, leaving a gab for the charter to jump between
User prompt
Make hero move 3x as fast
User prompt
do #1
User prompt
Make the game harder the longer the player stays alive
User prompt
After game over more obstacles spawn
User prompt
Make the obstacle spawn rate fixed
User prompt
Add score to the game
User prompt
Make obstacles move twice as fast
User prompt
Obstacles sometimes spawn such that it's impossible to survive
User prompt
Obstacles should spawn at random and the top and move towards the player. If an obstacle hit the player. you should be game over and the game should restart.
User prompt
Show the three tracks that the player is running on.
User prompt
Make switching lanes much faster
User prompt
Make charter animate between lanes, when switching lanes.
User prompt
Space lanes further apart.
Initial prompt
Obstacles should appear in in three fixed lanes. Swiping the mouse left and right should move the charter between these 3 lanes. Charter should show at the bottom of the play area.
//Always include this, it helps AI's //@include('ai-support.js') XS.stageContainer.setBackgroundColor(0x0); function game() { /** Entity Classes **/ var Player = Container.expand(function() { var self = Container.call(this); //{0} var playerGraphics = XS.getAsset('player', 'Medieval Runner Character'); playerGraphics.anchor.set(0.5, 0.5); self.addChild(playerGraphics); this.targetX = null; //{1} this.speed = 20; this.moveToLane = function(targetX) { this.targetX = targetX; }; //{2} this.update = function() { //{3} if (this.targetX !== null) { var direction = this.targetX > this.x ? 1 : -1; this.x += direction * this.speed; if (direction > 0 && this.x >= this.targetX || direction < 0 && this.x <= this.targetX) { this.x = this.targetX; this.targetX = null; //{4} } //{5} } //{6} }; //{7} }); //{8} var Obstacle = Container.expand(function() { var self = Container.call(this); //{9} var obstacleGraphics = XS.getAsset('obstacle', 'Medieval Obstacle'); obstacleGraphics.anchor.set(0.5, 0.5); self.addChild(obstacleGraphics); this.speed = 10; this.update = function() { //{10} this.y += this.speed; }; //{11} }); //{12} /** Main Class **/ var MedievalRunner = Container.expand(function() { var self = Container.call(this); //{13} var score = 0; var scoreText = new Text2(score, { size: 150, font: "'GillSans-Bold',Impact,'Arial Black',Tahoma", fill: "#ffffff" }); //{14} scoreText.anchor.set(0.5, 0); XS.gui.top.addChild(scoreText); var lanes = [512, 1024, 1536]; // Three lanes for the player to move between var trackGraphics = []; lanes.forEach(function(lane) { var track = XS.getAsset('track', 'Medieval Runner Track'); track.anchor.set(0.5, 0); track.x = lane; track.y = 0; trackGraphics.push(track); self.addChild(track); }); //{15} var player = self.addChild(new Player()); player.y = 2732 - player.height; // Position the player at the bottom of the screen player.x = lanes[1]; // Start the player in the middle lane var obstacles = []; function spawnObstacle(lane) { var obstacle = new Obstacle(); obstacle.x = lane; obstacle.y = -obstacle.height; obstacles.push(obstacle); self.addChild(obstacle); } //{16} var lastSpawnedLane = null; function spawnObstacleRandomly() { var availableLanes = lanes.filter(lane => lane !== lastSpawnedLane); var newLane = availableLanes[Math.floor(Math.random() * availableLanes.length)]; lastSpawnedLane = newLane; spawnObstacle(newLane); XS.setTimeout(spawnObstacleRandomly, 2000); } //{17} spawnObstacleRandomly(); function updateGame() { player.update(); obstacles.forEach(function(obstacle) { //{18} obstacle.update(); if (obstacle.y > player.y && !obstacle.passed) { score++; scoreText.setText(score); //{19} obstacle.passed = true; } //{20} if (player.intersects(obstacle)) { XS.showGameOver(restartGame); } //{21} }); //{22} } //{23} XS.on('tick', updateGame); var swipeStartX = null; stage.on('down', function(obj) { swipeStartX = obj.event.getLocalPosition(stage).x; }); //{24} stage.on('up', function(obj) { var swipeEndX = obj.event.getLocalPosition(stage).x; var swipeDistance = swipeEndX - swipeStartX; if (swipeDistance > 100 && player.x < lanes[2]) { // Swipe right player.moveToLane(lanes[lanes.indexOf(player.x) + 1]); } else if (swipeDistance < -100 && player.x > lanes[0]) { // Swipe left player.moveToLane(lanes[lanes.indexOf(player.x) - 1]); } //{25} swipeStartX = null; }); //{26} function restartGame() { obstacles.forEach(function(obstacle) { //{27} obstacle.destroy(); }); //{28} obstacles = []; player.x = lanes[1]; player.y = 2732 - player.height; score = 0; scoreText.setText(score); //{29} } //{30} }); //{31} /** Initialize the 'main class' and attach it to stage **/ var medievalRunner = new MedievalRunner(); stage.addChild(medievalRunner); function positionElements() { medievalRunner.x = (stage.width - 2048) / 2; } //{32} positionElements(); XS.on('resize', positionElements); } //{33}
===================================================================
--- original.js
+++ change.js
@@ -84,62 +84,62 @@
spawnObstacle(newLane);
XS.setTimeout(spawnObstacleRandomly, 2000);
} //{17}
- spawnObstacleRandomly(); //{18}
+ spawnObstacleRandomly();
function updateGame() {
player.update();
- obstacles.forEach(function(obstacle) { //{19}
+ obstacles.forEach(function(obstacle) { //{18}
obstacle.update();
if (obstacle.y > player.y && !obstacle.passed) {
score++;
- scoreText.setText(score); //{20}
+ scoreText.setText(score); //{19}
obstacle.passed = true;
- } //{21}
+ } //{20}
if (player.intersects(obstacle)) {
XS.showGameOver(restartGame);
- } //{22}
- }); //{23}
- } //{24}
+ } //{21}
+ }); //{22}
+ } //{23}
XS.on('tick', updateGame);
var swipeStartX = null;
stage.on('down', function(obj) {
swipeStartX = obj.event.getLocalPosition(stage).x;
- }); //{25}
+ }); //{24}
stage.on('up', function(obj) {
var swipeEndX = obj.event.getLocalPosition(stage).x;
var swipeDistance = swipeEndX - swipeStartX;
if (swipeDistance > 100 && player.x < lanes[2]) { // Swipe right
player.moveToLane(lanes[lanes.indexOf(player.x) + 1]);
} else if (swipeDistance < -100 && player.x > lanes[0]) { // Swipe left
player.moveToLane(lanes[lanes.indexOf(player.x) - 1]);
- } //{26}
+ } //{25}
swipeStartX = null;
- }); //{27}
+ }); //{26}
function restartGame() {
- obstacles.forEach(function(obstacle) { //{28}
+ obstacles.forEach(function(obstacle) { //{27}
obstacle.destroy();
- }); //{29}
+ }); //{28}
obstacles = [];
player.x = lanes[1];
player.y = 2732 - player.height;
score = 0;
- scoreText.setText(score); //{30}
- spawnObstacleRandomly(); //{31}
- } //{32}
- }); //{33}
+ scoreText.setText(score); //{29}
+ } //{30}
+ }); //{31}
+
/** Initialize the 'main class' and attach it to stage **/
var medievalRunner = new MedievalRunner();
stage.addChild(medievalRunner);
function positionElements() {
medievalRunner.x = (stage.width - 2048) / 2;
- } //{34}
+ } //{32}
positionElements();
XS.on('resize', positionElements);
-} //{35}
\ No newline at end of file
+} //{33}
\ No newline at end of file
Single subway surfer character. Running upwards. Camera from right above. Game Texture. In-Game asset. 2d. Pixelart. White background. Blank background. Low detail. High contrast.
Single train car. Topdown view. Subway surfers. 2d. Game Texture. In-Game asset. 2d. Pixelart. White background. Blank background. Low detail. High contrast.