Share your repls and programming experiences

← Back to all posts
dashy dash game REMASTERED
CursorsDev (733)

heyo, dashy dash was pretty nice, but i took it to the next level with starz (the name of this game).

starz is about a color hole (a black hole, but colorful) trying to eat other stars. unfortunately, bob (the hole's name) can only eat starz the same color as him. fortunately, bob can change colors by pressing the space bar.

try to survive and get the most points :)

controls:

WASD or arrow keys to move
Space to change color/boost

hacks:

v Key - Vector; see where you are going
l Key - Lines; see where stars are going
c Key - Color; see where stars the same color as you are going

How it was made

Alright, time to get technical. First off, I would like to review the enemies in the game. They may seem smarter than my previous games' enemies, but in reality, they are the same. The only difference is that they follow an offset from the player, not the player themselves.

This makes it seem like they have minds of their own and sometimes they 'dodge' your dive.

Next I want to talk about game design. The principle is still the same; you dash around and defeat enemies. What's different is that now you can always defeat SOMETHING, but there are a lot more things that can defeat YOU.

There's not much to talk about actually.

bacc to my olde style of talking ig.

Comments
hotnewtop
noway15 (97)

dashy dash 2 lol

LeoXu2 (43)

go to console and input this setInterval(function() {spawn()}, 1);

dustdude (9)

i like how u can just hop into the wall and come out the other side, useful when ur cornered

JuanjoseCaycedo (0)

OMG BRO I JUST GOT 513 SCORE RN!!

Interlink (23)


I made the orbs spawn instantly, made the color list only red and turned on bot trails
also boost makes me go super fast so i got like 1000 score or smth but this isnt that

Interlink (23)


here it is
highest i could get before it was about to crash

dustdude (9)

@thetwinkybob how'd u make the orbs spawn instantly? sry im a noob

CyberHacker101 (136)

Dude ur repls KEEP getting better are you some type of wizard or something

Interlink (23)

nice
I am not sure how to use the cheats but pretty fun.

Interlink (23)

edit, I get it now but the | command doesnt seem to work

JuanjoseCaycedo (0)

WOOO 77 seconds 96 score

epicman702 (497)

I'm getting an error?

BanditBoiz (0)
<!DOCTYPE html><html> <head> <title>starz</title> <style> html { height: 100%; overflow: hidden; }
        body {
            height: 100%;
            margin: 0;
            background-color: black;
            display: grid;
            place-items: center;
        }
        
        canvas {
            width: 100vw;

height: calc(100vw * (9/16));
background-color: black;
border: 1px solid white;
box-sizing: border-box;
}
</style>

</head>
<body>
    <canvas id="canvas"></canvas>
    <script>
        const canvas = document.getElementById("canvas");
        const ctx = canvas.getContext("2d");
        canvas.width = 1600;
        canvas.height = 900;
        
        let lines = false;
        let vel = false;
        let clr = false;
        
        class Ball {
            static colors = ["red", "orange", "yellow", "green", "blue", "indigo", "violet"];
        
            constructor(x, y, r) {
                this.x = x;
                this.y = y;
                this.r = r;
                
                this.i = 0;
                this.c = Ball.colors[this.i];
                this.canChange = true;
                this.boost = false;
                
                this.yv = 0;
                this.xv = 0;
            }
            
            update(deltaTime) {
                this.x += this.xv * deltaTime;
                this.y += this.yv * deltaTime;
                
                this.xv *= 0.99;
                this.yv *= 0.99;
                
                if (Math.abs(this.xv) < 8) this.xv = 0;
                if (Math.abs(this.yv) < 8) this.yv = 0;
                
                if (this.xv < 8 && this.xv) this.xv += 4;
                if (this.yv < 8 && this.yv) this.yv += 4;
                if (this.xv > 8 && this.xv) this.xv -= 4;
                if (this.yv > 8 && this.yv) this.yv -= 4;
                
                if (keys["KeyA"] || keys["ArrowLeft"]) this.xv -= 10;
                if (keys["KeyD"] || keys["ArrowRight"]) this.xv += 10;
                if (keys["KeyW"] || keys["ArrowUp"]) this.yv -= 10;
                if (keys["KeyS"] || keys["ArrowDown"]) this.yv += 10;
                
                if (this.xv > 300) this.xv = 300;
                if (this.xv < -300) this.xv = -300;
                if (this.yv > 300) this.yv = 300;
                if (this.yv < -300) this.yv = -300;
                
                if ((keys["KeyA"] && keys["KeyW"]) ||
                    (keys["KeyA"] && keys["KeyS"]) ||
                    (keys["KeyD"] && keys["KeyW"]) ||
                    (keys["KeyD"] && keys["KeyS"]) ||
                    (keys["ArrorLeft"] && keys["ArrowUp"]) ||
                    (keys["ArrowLeft"] && keys["ArrowDown"]) ||
                    (keys["ArrowRight"] && keys["ArrowUp"]) ||
                    (keys["ArrowRight"] && keys["ArrowDown"])
                ) {
                    this.yv *= 0.985;
                    this.xv *= 0.985;
                }
                
                if (keys["Space"] && this.canChange) {
                    this.i++;
                    this.c = Ball.colors[this.i % Ball.colors.length];
                    this.canChange = false;
                    this.boost = true;
                    setTimeout(() => this.canChange = true, 1500);
                    setTimeout(() => this.boost = false, 500);
                }
                
                if (this.boost) {
                    this.xv *= 1.25;
                    this.yv *= 1.25;
                }
                
                if (this.x + this.r < 0) {
                    this.x = canvas.width - this.r;
                } else if (this.x - this.r > canvas.width) {
                    this.x = 0 + this.r;
                }
                
                if (this.y + this.r < 0) {
                    this.y = canvas.height - this.r;
                } else if (this.y - this.r > canvas.height) {
                    this.y = 0 + this.r;
                }
                
                this.draw();
            }
            
            draw() {
                ctx.fillStyle = this.c;
                ctx.beginPath();
                ctx.arc(this.x, this.y, this.r, 0, Math.PI * 2, false);
                ctx.closePath();
                ctx.fill();
                
                if (vel) {
                    ctx.strokeStyle = this.c;
                    ctx.beginPath();
                    ctx.moveTo(this.x, this.y);
                    ctx.lineTo(this.x + this.xv, this.y + this.yv);
                    ctx.closePath();
                    ctx.stroke();
                }
            }
        }
        
        class Enemy {
            static enemies = [];
        
            constructor(x, y, c, tx, ty) {
                this.x = x;
                this.y = y;
                this.c = c;
                this.r = 8;
                this.tx = tx;
                this.ty = ty;
            }
        
            update(deltaTime) {
                const dx = this.x - ball.x + this.tx;
                const dy = this.y - ball.y + this.ty;
                const d = Math.sqrt(dx * dx + dy * dy);
                
                if (this.c === ball.c) {
                    this.x += dx / d;
                    this.y += dy / d;
                } else {
                    this.x -= dx / d;
                    this.y -= dy / d;
                }
                
                if (this.x + this.r < 0) {
                    this.x = canvas.width - this.r;
                } else if (this.x - this.r > canvas.width) {
                    this.x = 0 + this.r;
                }
                
                if (this.y + this.r < 0) {
                    this.y = canvas.height - this.r;
                } else if (this.y - this.r > canvas.height) {
                    this.y = 0 + this.r;
                }
                
                if (ball.boost) {
                    this.x += Math.random() * 2 - 1;
                    this.y += Math.random() * 2 - 1;
                }
                
                this.draw();
            }
        
            draw() {
                ctx.fillStyle = this.c;
                ctx.beginPath();
                ctx.arc(this.x, this.y, this.r, 0, Math.PI * 2, false);
                ctx.closePath();
                ctx.fill();
                
                if (lines || (clr && this.c === ball.c)) {
                    ctx.strokeStyle = this.c;
                    ctx.beginPath();
                    ctx.moveTo(this.x, this.y);
                    ctx.lineTo(ball.x - this.tx, ball.y - this.ty);
                    ctx.closePath();
                    ctx.stroke();
                }
            }
        }
        
        const ball = new Ball(canvas.width / 2, canvas.height / 2, 18);
        
        let deltaTime = 0;
        let lastTime = 0;
        let pts = 0;
        let gameOver = false;
        let frame = 0;
        
        ctx.textAlign = "center";
        
        function animate(ms) {
            if (gameOver) return;
            
            const time = ms / 1000;
            deltaTime = time - lastTime;
            lastTime = time;
            
            ctx.fillStyle = "rgba(0, 0, 0, 0.1)";
            ctx.fillRect(0, 0, canvas.width, canvas.height);
            
            ball.update(deltaTime);
            
            ctx.font = "16px monospace";
            ctx.fillStyle = "white";
            ctx.fillText(pts, ball.x, ball.y + ball.r / 2 - 3);
            
            Enemy.enemies.forEach((e, i) => {
                e.update(deltaTime);
                
                if (Math.sqrt(Math.pow(e.x - ball.x, 2) + Math.pow(e.y - ball.y, 2)) < e.r + ball.r) {
                    if (ball.c === e.c) {
                        Enemy.enemies.splice(i, 1);
                        pts++;
                    } else {
                        gameOver = true;
                        cancelAnimationFrame(req);
                        ctx.font = "96px monospace";
                        ctx.fillStyle = "lightgreen";
                        ctx.fillText(`game over`, canvas.width / 2, canvas.height / 2);
                        ctx.font = "36px monospace";
                        ctx.fillText(`time: ${Math.floor(frame / 60)} seconds`, canvas.width / 2, canvas.height / 2 + 72);
                        ctx.fillText(`score: ${pts}`, canvas.width / 2, canvas.height / 2 + 128);
                        setTimeout(() => location.reload(), 2500);
                    }
                }
            });
            
            req = requestAnimationFrame(animate);
            
            frame++;
        }
        
        let req = requestAnimationFrame(animate);
        
        const keys = {};
        
        document.addEventListener("keydown", (e) => {
            if (e.code === "KeyL") lines = !lines;
            if (e.code === "KeyV") vel = !vel;
            if (e.code === "KeyC") clr = !clr;
            keys[e.code] = true;
        });
        
        document.addEventListener("keyup", (e) => {
            delete keys[e.code];
        });
        
        let time = 2500;
        
        function spawn() {
            let x = Math.floor(Math.random() * (canvas.width - 16));
            let y = Math.floor(Math.random() * (canvas.height - 16));
            while (Math.sqrt(Math.pow(x - ball.x, 2) + Math.pow(y - ball.y, 2)) < 256) {
                x = Math.floor(Math.random() * (canvas.width - 16));
                y = Math.floor(Math.random() * (canvas.height - 16));
            }
            const enemy = new Enemy(
                x, 
                y, 
                Ball.colors[Math.floor(Math.random() * Ball.colors.length)],
                Math.round(Math.random() * ball.r * 16 - ball.r * 8),
                Math.round(Math.random() * ball.r * 16 - ball.r * 8),
            );
            Enemy.enemies.push(enemy);
            time -= 50;
            if (time < 500) time = 500;
            setTimeout(spawn, time);
        }
        
        setTimeout(spawn, time);
    </script>
</body>
</html>
SudhanshuMishra (252)

why is this game so cool and interesting and beautiful and attractive and calming and loream ipsum dolor sit amet some text to apprciate

SudhanshuMishra (252)

hello how many marks you got in your mathematics exam ? :)

KhShahid (13)

so hard pls make a option for kill them

[deleted]

Wow, this game is absolutely awesome, great job dude!

[deleted]

What do i do?

DSAEvan (27)

How do you get points?

NotMrMan (119)

@DSAEvan by pressing space to change color so you can eat the blobs that are the same color as you.

DavidHilsee (3)

Found a bug, if an enemy reaches the end of their path and don't collide with you along the way, they just stop moving and stay in the same place relative to you.

CursorsDev (733)

@DavidHilsee not a bug, im just too lazy to make it do something else :)

Kudos (139)


It hasn't hit me yet, sus.

Baconman321 (1103)

Nice! Again tho, make it so it doesn't reload on game over. Also make sure to get rid of unused objects at the end of the game so a memory leak doesn't occur.

CursorsDev (733)

ha im too lazy to do that. and dont worry about a mem leak. its as easy as Enemy.enemies = []; ;)

SudhanshuMishra (252)

LEAVE ME ALOOOOONNEEEEE !!!!!!