Alright, I’ll give you a detailed, full, step-by-step guide to create Neon Drift: Time Hacker on your mobile device, optimized for simplicity and a premium neon cyberpunk look. Since you’re working on a phone without a laptop, I’ll ensure every step is mobile-friendly. I’ll also explain how to host it on Blogger (Google’s free blogging platform), as you requested, instead of Netlify. Let’s dive in!
Overview
- Goal: Build a lightweight, mobile-compatible web game with Phaser.js.
- Tools: All free, accessible via your mobile browser.
- Hosting: Embed the game in a Blogger post.
- Time: ~1-2 hours, depending on your pace.
Tools You’ll Need
- Code Editor: CodePen (codepen.io) – Free, mobile-friendly, no downloads needed.
- Browser: Chrome or Safari on your phone.
- Assets: Free sprites from Kenney.nl (downloadable on mobile).
- Blogger: Your existing Blogger account (blogger.com) to host the game.
- Optional: A file manager app (e.g., “Files” on Android) to handle downloads.
Step-by-Step Guide
Step 1: Set Up CodePen on Your Mobile
- Open Browser:
- Launch Chrome or Safari on your phone.
- Go to CodePen:
- Type codepen.io in the address bar and press Enter.
- Sign Up or Log In:
- Tap the menu (three lines or dots, top-right).
- Choose “Sign Up” (free) or “Log In” if you have an account. Use your Google account for speed.
- Skip this if you want to work as a guest (but saving requires an account).
- Create a New Pen:
- Tap “Create” (top menu) > “New Pen”.
- You’ll see three boxes: HTML, CSS, JS.
Step 2: Add the Game Code
We’ll write everything in one go, then test it. I’ll break it into sections for clarity.
- HTML Section:
- Paste this into the HTML box:
html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Neon Drift: Time Hacker</title>
<link href="https://fonts.googleapis.com/css2?family=Orbitron&display=swap" rel="stylesheet">
</head>
<body>
<div id="game-container"></div>
<script src="https://cdn.jsdelivr.net/npm/phaser@3.55.2/dist/phaser.min.js"></script>
</body>
</html>- Explanation:
- viewport ensures mobile scaling.
- Orbitron font adds a sci-fi vibe.
- game-container is where Phaser renders the game.
- Phaser.js is loaded via CDN.
- CSS Section:
- Paste this into the CSS box:
css
body {
margin: 0;
padding: 0;
background: #0a0a1a; /* Dark cyberpunk blue */
overflow: hidden;
}
#game-container {
width: 100%;
height: 100vh; /* Full screen height */
}
canvas {
display: block;
width: 100%;
height: 100%;
}- Explanation:
- Dark background sets the neon mood.
- Full-screen canvas ensures mobile compatibility.
- JS Section:
- Paste this into the JS box:
javascript
// Game config
const config = {
type: Phaser.AUTO,
width: window.innerWidth,
height: window.innerHeight,
parent: 'game-container',
scene: { preload, create, update },
physics: { default: 'arcade', arcade: { gravity: { y: 0 } } },
fps: { target: 60 }
};
const game = new Phaser.Game(config);
let player, obstacles, timeChips, score = 0, distance = 0, speed = 150;
let timeHackActive = false, timeHackCooldown = 0;
function preload() {
// Free Kenney assets
this.load.image('tunnel-bg', 'https://kenney.nl/assets/abstract-platformer/Backgrounds/background_03.png');
this.load.image('player', 'https://kenney.nl/assets/abstract-platformer/Player/player_02.png');
this.load.image('firewall', 'https://kenney.nl/assets/abstract-platformer/Obstacles/obstacle_02.png');
this.load.image('chip', 'https://kenney.nl/assets/abstract-platformer/Items/item_01.png');
}
function create() {
// Neon tunnel background
this.bg = this.add.tileSprite(0, 0, game.config.width, game.config.height, 'tunnel-bg')
.setOrigin(0, 0);
// Player with neon glow and pulse
player = this.physics.add.sprite(game.config.width / 2, game.config.height - 50, 'player')
.setTint(0x00ffff) // Cyan glow
.setScale(0.5);
player.setCollideWorldBounds(true);
this.tweens.add({ targets: player, scale: 0.6, duration: 500, yoyo: true, repeat: -1 });
// Groups
obstacles = this.physics.add.group();
timeChips = this.physics.add.group();
// Touch controls
this.input.on('pointermove', (pointer) => {
player.x = pointer.x;
});
// Time Hack (two-finger tap)
this.input.on('pointerdown', () => {
if (this.input.pointer1.isDown && this.input.pointer2.isDown && !timeHackActive && timeHackCooldown <= 0) {
activateTimeHack(this);
}
});
// Spawn obstacles and chips
this.time.addEvent({ delay: 2000, callback: spawnObstacle, callbackScope: this, loop: true });
this.time.addEvent({ delay: 4000, callback: spawnChip, callbackScope: this, loop: true });
// Score text
this.scoreText = this.add.text(10, 10, 'Score: 0', { font: '16px Orbitron', fill: '#ff00ff' });
}
function update() {
// Scroll background
this.bg.tilePositionY -= 2;
// Increase difficulty
distance += 1;
if (distance % 1800 === 0) speed += 30;
// Update score
score = Math.floor(distance / 60) + timeChips.countActive(false) * 10;
this.scoreText.setText(`Score: ${score}`);
// Time Hack cooldown
if (timeHackCooldown > 0) timeHackCooldown -= 1 / 60;
// Collisions
this.physics.overlap(player, obstacles, gameOver, null, this);
this.physics.overlap(player, timeChips, collectChip, null, this);
}
function spawnObstacle() {
let x = Phaser.Math.Between(20, game.config.width - 20);
let obstacle = obstacles.create(x, -20, 'firewall')
.setTint(0xff0000) // Red glow
.setScale(0.5)
.setVelocityY(speed);
}
function spawnChip() {
let x = Phaser.Math.Between(20, game.config.width - 20);
let chip = timeChips.create(x, -20, 'chip')
.setTint(0xffff00) // Yellow glow
.setScale(0.5)
.setVelocityY(speed / 2);
}
function activateTimeHack(scene) {
timeHackActive = true;
scene.time.timeScale = 0.3; // Slow motion
scene.time.delayedCall(3000, () => {
scene.time.timeScale = 1;
timeHackActive = false;
timeHackCooldown = 10;
});
}
function collectChip(player, chip) {
chip.destroy();
}
function gameOver() {
this.physics.pause();
this.add.text(game.config.width / 2, game.config.height / 2, 'Game Over', {
font: '24px Orbitron',
fill: '#ff00ff'
}).setOrigin(0.5);
let highScore = localStorage.getItem('highScore') || 0;
if (score > highScore) {
localStorage.setItem('highScore', score);
alert('New High Score: ' + score);
} else {
alert('Score: ' + score + '\nHigh Score: ' + highScore);
}
}- Explanation:
- Assets: Free Kenney sprites via URLs (no uploads needed).
- Controls: Swipe to move, two-finger tap for Time Hack.
- Visuals: Neon tints (cyan, red, yellow), pulsing player, scrolling tunnel.
- Score: Distance + chips, with local high score storage.
- Save:
- Tap the “Save” button (top-right in CodePen).
- Name it “Neon Drift: Time Hacker” when prompted.
Step 3: Test the Game on Your Phone
- Preview:
- Tap the “eye” icon (bottom-right) or swipe to the preview pane in CodePen.
- The game should load full-screen.
- Play:
- Swipe left/right to move the player.
- Tap with two fingers to slow time (3-second slow-mo, 10-second cooldown).
- Dodge red firewalls, collect yellow chips.
- When you hit an obstacle, see the “Game Over” screen with your score.
- Adjust:
- If it’s too fast, lower speed = 150 to speed = 100 in JS.
- If too slow, increase speed or reduce spawn delays (e.g., 2000 to 1500).
Step 4: Make It Premium-Looking
- Neon Glow: Already added with setTint (cyan player, red obstacles, yellow chips).
- Pulse Effect: Player pulses via tween (see create()).
- Font: Orbitron gives a sci-fi premium feel.
- Background: Scrolling tunnel adds depth. For extra flair, tweak tilePositionY -= 2 to 3 for faster scrolling.
Step 5: Host on Blogger
Blogger doesn’t host files directly, but you can embed the game using CodePen’s iframe or raw code. Here’s how:
- Get the Full Code:
- In CodePen, tap “Export” > “Export as ZIP” (bottom-right).
- Download the ZIP to your phone.
- Use a file manager app (e.g., “Files”) to unzip it. You’ll get index.html, style.css, etc.
- Open index.html in a text editor (e.g., “QuickEdit” app, free on Play Store) and copy all the code. OR combine manually:
html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Neon Drift: Time Hacker</title>
<link href="https://fonts.googleapis.com/css2?family=Orbitron&display=swap" rel="stylesheet">
<style>
body { margin: 0; padding: 0; background: #0a0a1a; overflow: hidden; }
#game-container { width: 100%; height: 100vh; }
canvas { display: block; width: 100%; height: 100%; }
</style>
</head>
<body>
<div id="game-container"></div>
<script src="https://cdn.jsdelivr.net/npm/phaser@3.55.2/dist/phaser.min.js"></script>
<script>
// Paste the entire JS code from Step 2 here
const config = { /* ... */ };
// ... (all the JS code up to gameOver function)
</script>
</body>
</html>- Log In to Blogger:
- Open blogger.com in your browser.
- Sign in with your Google account.
- Tap “New Post”.
- Embed the Game:
- Option 1: Raw HTML (Preferred):
- In the Blogger editor, tap the “HTML” view (not “Compose”).
- Paste the full combined code from above.
- Switch back to “Compose” to add a title (e.g., “Play Neon Drift!”).
- Option 2: CodePen Iframe (Simpler):
- In CodePen, tap “Share” > copy the “Embed” code (looks like <iframe src="..." ...>).
- In Blogger, go to “HTML” view, paste the iframe:
html
<iframe height="800" style="width: 100%;" scrolling="no" title="Neon Drift: Time Hacker" src="YOUR_CODEPEN_URL" frameborder="no" allowtransparency="true" allowfullscreen="true"></iframe> - Replace `YOUR_CODEPEN_URL` with the link from CodePen (e.g., `https://codepen.io/your-username/embed/your-pen-id`).- Publish:
- Tap “Publish” in Blogger.
- Wait a few seconds, then visit your blog post URL (e.g., yourblog.blogspot.com/2025/04/neon-drift.html).
- The game should load full-screen!
Step 6: Final Touches
- Test on Blogger:
- Open the post on your phone.
- Swipe to move, two-finger tap for Time Hack.
- Ensure it’s playable (might need slight zoom adjustment).
- Fix Issues:
- If it’s too small, add style="width: 100%; height: 100vh;" to the iframe or <div id="game-container">.
- If assets don’t load, check URLs in JS (they’re public Kenney links, should work).
Hosting on Blogger: Pros & Cons
- Pros:
- Free, no extra accounts needed beyond Google.
- Easy to share with a blog post.
- Cons:
- No custom domain (e.g., yourgame.com).
- Iframe or HTML embedding might have slight mobile quirks (e.g., scrolling issues).
- Can’t add ads or payments easily (needs external hosting like Netlify for that).
Premium Enhancements
- Sound: Add free SFX later (e.g., from Zapsplat.com) if you get access to a file uploader.
- Menu: Add a start button by wrapping the game in a <div> (ask if you want code).
- Custom Assets: Use a mobile app like PicsArt to tweak Kenney sprites with neon glows.
Try It Now!
- Start in CodePen with the code above.
- Test it, tweak as needed (e.g., speed or spawn rates).
- Embed in Blogger and share the link with friends!
Let me know how it goes or if you hit any snags—I’ll guide you through fixes step-by-step. What do you think so far? Ready to start coding?