You are browsing as a guest. Sign up (or log in) to start making projects!

harsht7

@harsht7

Joined June 1st, 2026

  • 2Devlogs
  • 2Projects
  • 0Ships
  • 0Votes
Open comments for this post

2h 7m 26s logged

Devlog #2 (a terminal snake game)
I’m back with my Rust project based learning journey (creating a rust project for the first time to help me out with another big project I’m thinking about)

TL;DR: I got input and basic game state done, a character in the terminal can move

Full version: Anyways, this devlog I got quite a bit done! I first started creating a simple Position struct, moved to create a simple Game class, then created Input matching using crossterm terminal library built in Events where I was getting confused between an “associated” fn vs a method and got into this thinking loop because of Result<Option<Command>> but basically you need to read it from inside out, if that helps! Also I can’t be more grateful for THE GOAT KEYWORD…drumroll…match! I don’t understand why other languages don’t have this, it’s way easier to handle enums this way! After being done with input, I added a input handling function to my game file to update player_pos. Then going back to main, I added a loop and made sure all the pieces fit together. I then did my first test where I saw movement working! but there were some issues that I resolved in later commits, like the character being in different places b/c of not clearing the screen before every redraw and adding a delay so that my CPU doesn’t BLOW UP from the loop. I still need to fix one thing though: the loop breaks even without me pressing the quit button after some time, so I need to figure out what’s doing that. I also need to make sure the terminal window size and character updating is synced. In the next devlog I’ll try to add some food and hopefully start adding some snake growing logic! Glad that I’ve got to learn crossterm, and hope to learn async and tokio, etc with rust in the future…

sorry for the yap, nevertheless, I think I took a bit long to create basic movement but I’m satisfied since it’s my first time. Also I uploaded a gif bc for some reason .mkv upload didn’t work

0
0
5
Open comments for this post

40m 30s logged

Devlog #1 (snakinal - a snake game in the terminal)

This is my first time in a long time doing something related to the terminal and also my first time with Rust 🦀 (I’ve fiddled with C++, so that background helps me connect to things in rust)! I’m going with a PBL (project based learning) route to quickly learn Rust (although I know Rust has a big learning curve). Also, shout out to Let’s Get Rusty’s rust learning playlist on YT.

Anyways, below I’ve managed to write something simple in the terminal through a bit of AI help. In this devlog I’ve learnt quite a bit of rust syntax:

  1. like how creating “classes” in rust has a 3 step procedure (struct, impl, and trait) instead of just class in other low level languages
  2. !() are macros that executes before compile time
  3. ?; is used on expressions that can return a success or fail, and to return the error immediately if it fails, also only works when the return type is Result<>
  4. learnt a bit about how crossterm library functions work
  5. also took me a year to understand why lsp/linting wouldn’t work for another file that I had. Apparently Rust doesn’t see files unless you do mod <filename> in main.rs
  6. One more thing that still slightly confuses me is the difference between :: & . and when to use one or the other (so if someone doesn’t mind commenting, I’d really appreciate!)

I hope this pointers have helped other beginner rusties, and if I’ve said something incorrect, rustaceans pls forgive me

0
0
42

Followers

Loading…