-
Notifications
You must be signed in to change notification settings - Fork 839
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4391f95
commit 13dc132
Showing
43 changed files
with
1,077 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# **Infinite_Cars** | ||
|
||
--- | ||
|
||
<br> | ||
|
||
## **Description 📃** | ||
- A car racing game with infinite number of cars trying to hit players car | ||
- Navigate the road and its dangers while gaining maximum points. | ||
|
||
## **How to play? 🕹️** | ||
|
||
- Controls | ||
- right click and hold the car and move using mouse. | ||
<br> | ||
|
||
## **Screenshots 📸** | ||
|
||
<br> | ||
|
||
![image](../../assets/images/infinite_cars.png) | ||
|
||
<br> |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+2.75 KB
Games/Infinite_Cars/assets/icons/infinite-cars-icon-android-144x144.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.9 KB
Games/Infinite_Cars/assets/icons/infinite-cars-icon-android-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+792 Bytes
Games/Infinite_Cars/assets/icons/infinite-cars-icon-android-36x36.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.09 KB
Games/Infinite_Cars/assets/icons/infinite-cars-icon-android-48x48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.03 KB
Games/Infinite_Cars/assets/icons/infinite-cars-icon-android-72x72.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.36 KB
Games/Infinite_Cars/assets/icons/infinite-cars-icon-android-96x96.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// background.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, width=device-width, user-scalable=no, minimal-ui" /> | ||
<meta name="apple-mobile-web-app-capable" content="yes" /> | ||
<meta name="full-screen" content="yes" /> | ||
<meta name="screen-orientation" content="portrait" /> | ||
<title>Infinite Cars</title> | ||
<link rel="stylesheet" href="./styles/infinite-cars.css" /> | ||
<script> | ||
console.clear(); | ||
</script> | ||
</head> | ||
<body> | ||
<script src="./scripts/libs/phaser.min.js"></script> | ||
<script type="module" src="./scripts/infinite-cars.processed.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
"use strict"; | ||
|
||
export const SCREEN_WIDTH = 320; | ||
export const SCREEN_HEIGHT = 480; | ||
|
||
export const MIN_SCREEN_WIDTH = SCREEN_WIDTH / 8; | ||
export const MIN_SCREEN_HEIGHT = SCREEN_HEIGHT / 8; | ||
|
||
export const MAX_SCREEN_WIDTH = SCREEN_WIDTH * 4; | ||
export const MAX_SCREEN_HEIGHT = SCREEN_HEIGHT * 4; | ||
|
||
export const CAMERA_FADE_TIME = 256; | ||
|
||
export const IMAGES_PATH = "./assets/images"; | ||
export const AUDIOS_PATH = "./assets/audios"; | ||
|
||
export const TILE_WIDTH = 32; | ||
export const TILE_HEIGHT = 32; | ||
export const ROAD_LAYOUT = [ | ||
"grass", | ||
"grass", | ||
"left-gutter", | ||
"left-road", | ||
"middle-road", | ||
"middle-road", | ||
"right-road", | ||
"right-gutter", | ||
"grass", | ||
"grass", | ||
]; | ||
export const ROAD_BOUNDARY = [96, 224]; | ||
|
||
export const GRASS_RATE = 20; | ||
export const GRASS_MAP = [ | ||
"tree", | ||
"flower", | ||
]; | ||
|
||
export const INITIAL_CHARACTER_X = SCREEN_WIDTH / 2; | ||
export const INITIAL_CHARACTER_Y = SCREEN_HEIGHT * 0.75; | ||
|
||
export const CHARACTER_SPEED = 192; | ||
|
||
export const ROAD_CONE_RATE = 6.5; | ||
export const COMPUTER_CAR_RATE = 6.5; | ||
|
||
export const COMPUTER_SLOW_SPEED_MIN = 96; | ||
export const COMPUTER_SLOW_SPEED_MAX = 144; | ||
|
||
export const COMPUTER_FAST_SPEED_MIN = 256; | ||
export const COMPUTER_FAST_SPEED_MAX = 320; | ||
|
||
export const COMPUTER_DODGE_DISTANCE = 240; | ||
export const COMPUTER_DODGE_SPEED = 48; | ||
|
||
export const STOP_LIGHT_WIDTH = 96; | ||
export const STOP_LIGHT_HEIGHT = 240; | ||
|
||
export const EXPLOSION_WIDTH = 32; | ||
export const EXPLOSION_HEIGHT = 32; | ||
|
||
export const GAME_START_TIME = 4000; | ||
|
||
export const FONT_FAMILY = "'Luckiest Guy', cursive"; | ||
export const FONT_SETTINGS = { | ||
fontFamily: FONT_FAMILY, | ||
fontSize: "24px", | ||
stroke: "#000000", | ||
strokeThickness: 4, | ||
}; | ||
|
||
export const SOUND_CONTROL_WIDTH = 16; | ||
export const SOUND_CONTROL_HEIGHT = 16; | ||
|
||
export const IS_DEBUG = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,192 @@ | ||
"use strict"; | ||
|
||
import * as Constants from "./Constants.js"; | ||
|
||
export function log(...message) { | ||
if (Constants.IS_DEBUG) { | ||
console.log(...message); | ||
} | ||
} | ||
|
||
export function isNullOrUndefined(obj) { | ||
return obj === undefined || obj === null; | ||
} | ||
|
||
export function random(min, max, flt) { | ||
flt = isNullOrUndefined(flt) ? 0 : flt; | ||
flt = 10 ** flt; | ||
min *= flt; | ||
max *= flt; | ||
|
||
return Math.round(Math.random() * (max - min) + min) / flt; | ||
} | ||
|
||
export function sceneEntry(scene) { | ||
log(`Entering "${scene.scene.key}" scene...`); | ||
|
||
scene.cameras.main.fadeIn(Constants.CAMERA_FADE_TIME); | ||
} | ||
|
||
export function moveScene(scene, nextSceneName) { | ||
log(`Exiting "${scene.scene.key}" scene...`); | ||
|
||
scene.cameras.main.fadeOut(Constants.CAMERA_FADE_TIME); | ||
|
||
scene.cameras.main.once("camerafadeoutcomplete", () => { | ||
log(`Moving to "${nextSceneName}" scene...`); | ||
|
||
scene.scene.start(nextSceneName); | ||
}, scene); | ||
} | ||
|
||
export function loadImage(scene, key, fileName) { | ||
scene.load.image(key, `${Constants.IMAGES_PATH}/${fileName}`); | ||
} | ||
|
||
export function loadSpriteSheet(scene, key, fileName, frameWidth, frameHeight) { | ||
scene.load.spritesheet(key, `${Constants.IMAGES_PATH}/${fileName}`, { | ||
frameWidth: frameWidth, | ||
frameHeight: frameHeight, | ||
}); | ||
} | ||
|
||
export function loadAudio(scene, key, fileName) { | ||
scene.load.audio(key, `${Constants.AUDIOS_PATH}/${fileName}`); | ||
} | ||
|
||
export function addGrassImage(scene, x, y) { | ||
if (random(0, 100) > Constants.GRASS_RATE) { | ||
return; | ||
} | ||
|
||
const selectedIndex = random(0, Constants.GRASS_MAP.length - 1); | ||
const textureKey = Constants.GRASS_MAP[selectedIndex]; | ||
|
||
const scoreImage = | ||
scene.add.image(x, y, textureKey) | ||
.setOrigin(random(0, 1, 3)) | ||
.setDepth(y + 2); | ||
} | ||
|
||
export function addMapRow(scene, y) { | ||
for (let i = 0; i < Constants.ROAD_LAYOUT.length; i++) { | ||
const textureKey = Constants.ROAD_LAYOUT[i]; | ||
const width = Constants.TILE_WIDTH; | ||
const x = i * width; | ||
|
||
let tile = scene.add.image(x, y, textureKey).setOrigin(0).setDepth(y); | ||
|
||
scene.roadGroup.add(tile); | ||
|
||
if (textureKey === "grass") { | ||
addGrassImage(scene, x, y); | ||
} | ||
} | ||
} | ||
|
||
export function createMap(scene) { | ||
log("Creating map layout..."); | ||
|
||
scene.roadGroup = scene.add.group(); | ||
|
||
const height = Constants.TILE_HEIGHT; | ||
|
||
for (let y = -(height); y < Constants.SCREEN_HEIGHT; y += height) { | ||
addMapRow(scene, y); | ||
} | ||
|
||
log("Map layout created"); | ||
} | ||
|
||
export function placeCharacter(scene, hasPhysics) { | ||
log("Initializing the character position..."); | ||
|
||
const x = Constants.INITIAL_CHARACTER_X; | ||
const y = Constants.INITIAL_CHARACTER_Y; | ||
|
||
if (hasPhysics === true) { | ||
scene.character = scene.physics.add.sprite(x, y, "character"); | ||
} | ||
else { | ||
scene.character = scene.add.image(x, y, "character"); | ||
} | ||
|
||
scene.character.setDepth(Constants.SCREEN_HEIGHT); | ||
|
||
log(`The character is place at ${x}, ${y}`); | ||
} | ||
|
||
export function createText(scene, text) { | ||
const button = scene.add.text( | ||
Constants.SCREEN_WIDTH / 2, | ||
Constants.SCREEN_HEIGHT / 1.25, | ||
text, Constants.FONT_SETTINGS) | ||
.setOrigin(0.5, 0.5) | ||
.setScrollFactor(0) | ||
.setDepth(Constants.SCREEN_HEIGHT) | ||
.setInteractive(); | ||
|
||
scene.tweens.add({ | ||
targets: button, | ||
alpha: 0, | ||
ease: "Sine.easeOut", | ||
duration: 1024, | ||
repeat: -1, | ||
yoyo: true, | ||
}); | ||
|
||
return button; | ||
} | ||
|
||
export function addText(scene, x, y, text, fontSize) { | ||
const settings = Constants.FONT_SETTINGS; | ||
|
||
settings.fontSize = fontSize; | ||
|
||
const obj = scene.add.text(x, y, text, settings) | ||
|
||
settings.fontSize = "24px"; | ||
|
||
return obj; | ||
} | ||
|
||
export function addSoundControl(scene) { | ||
log("Creating sound control button..."); | ||
|
||
scene.soundControl = scene.add.sprite( | ||
Constants.SCREEN_WIDTH - Constants.SOUND_CONTROL_WIDTH - 16, 16, "sound") | ||
.setOrigin(0) | ||
.setScrollFactor(0) | ||
.setDepth(Constants.SCREEN_HEIGHT) | ||
.setInteractive(); | ||
|
||
if (scene.sound.mute === true) { | ||
scene.soundControl.setFrame(1); | ||
} | ||
|
||
scene.soundControl.on("pointerdown", (pointer, x, y, evt) => { | ||
evt.stopPropagation(); | ||
|
||
log("Sound control clicked"); | ||
|
||
let isMuted = !scene.sound.mute; | ||
|
||
scene.sound.setMute(isMuted); | ||
scene.selectSound.play(); | ||
|
||
scene.soundControl.setFrame((isMuted === true) ? 1 : 0); | ||
|
||
log(`Sound set to ${isMuted === true ? "Mute" : "Unmute"}`); | ||
}); | ||
|
||
log("Sound control button created"); | ||
} | ||
|
||
export function addAudios(scene) { | ||
scene.accelerateSound = scene.sound.add("accelerate"); | ||
scene.crashedSound = scene.sound.add("crashed"); | ||
scene.driveSound = scene.sound.add("drive"); | ||
scene.overtakeSound = scene.sound.add("overtake"); | ||
scene.selectSound = scene.sound.add("select"); | ||
scene.startSound = scene.sound.add("start"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import * as Constants from "./includes/Constants.js"; | ||
|
||
import LoadingScene from "./scenes/LoadingScene.js"; | ||
import MainScene from "./scenes/MainScene.js"; | ||
import GameScene from "./scenes/GameScene.js"; | ||
|
||
new Phaser.Game({ | ||
type: Phaser.AUTO, | ||
parent: "infinite-cars", | ||
pixelArt: true, | ||
physics: { | ||
default: "arcade", | ||
arcade: { | ||
debug: Constants.IS_DEBUG, | ||
}, | ||
}, | ||
scale: { | ||
mode: Phaser.Scale.FIT, | ||
autoCenter: Phaser.Scale.CENTER_BOTH, | ||
width: Constants.SCREEN_WIDTH, | ||
height: Constants.SCREEN_HEIGHT, | ||
min: { | ||
width: Constants.MIN_SCREEN_WIDTH, | ||
height: Constants.MIN_SCREEN_HEIGHT, | ||
}, | ||
max: { | ||
width: Constants.MAX_SCREEN_WIDTH, | ||
height: Constants.MAX_SCREEN_HEIGHT, | ||
}, | ||
}, | ||
scene: [ | ||
LoadingScene, | ||
MainScene, | ||
GameScene, | ||
], | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.