Legal Cannabis Clears Key Hurdle in New Mexico

Marijuana legalization continued its roll on Saturday, after New Mexico’s House Health and Human Services committee voted to advance House Bill 356. The proposal passed the committee on a party-line…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Snake Your Way into Game Development with Pygame

Welcome to the first edition of our new foray into the wacky and wonderful world of (incredibly basic) game development. And, what’s our first stop, you ask? None other than the blast-from-the-past, the classic, the never-gets-old — Snake Game! 🐍

But first, let’s set the scene. It’s 1997. You’re ignoring your homework, your Nokia 3310 in hand, eyes glued to that pixelated screen, maneuvering a line that’s supposed to be a snake. Oh, the nostalgia!

Fast forward to 2023, we’re bringing that bad boy back to life with a twist — by coding it ourselves! That’s right! We’re pulling our socks up and diving headfirst into the riveting realm of Pygame.

So, grab a cup of coffee, buckle up, and let’s slither our way into the Python world! 🚀

When you’re coding a game, you’ve got to start with the basics. The screen! The colors! The clock! For our slithering friend, we need a nice 800x600 screen to roam around in. Just imagine it as your pet snake’s vivarium.

The colours? We’re going retro, folks. Only red, green and black for now (with white for our text). Although, rumour has it our snake might be looking a little green around the gills. And the clock, you ask? Well, it’s not that kind of clock. It’s to control the speed of our game. After all, we don’t want our snake speeding around like it just drank 5 cans of energy drink. 🚀

Now comes the real fun part: the snake itself! We’re keeping it simple here. Just a black (or dark green if you fancy) rectangle that grows every time it chomps on some food. But beware! If it hits the edge of the screen or its own tail, it’s game over. It might be a game, but it’s survival of the fittest out here, folks!

And remember, we’ll be following the golden rule of coding: DRY — Don’t Repeat Yourself. So we’ll create a function for our snake, making our code clean and readable. That’s what we call coding best practice, ladies and gentlemen!

And there you have it, folks! Your very own snake game. From a simple rectangle to a living, breathing (well…kind of), apple-munching snake! Isn’t coding just amazing?

(a quick sneak peak)

Thanks for reading!

Add a comment

Related posts:

Transfixed

blank faces staring down, transfixed on a game. wake up and look around.. “Transfixed” is published by Dillon Garrett Carr.

Train Your Mind To Be Present

Most people spend their waking hours worrying about the future instead of focusing on what’s in front of them. Being on autopilot mode has its benefits for mundane activities, such as driving…

Controlling the Project Cost with EVA

According to the PMBOK Guide®, Project Cost Management includes the processes to plan, estimate, budget, finance, fund, manage, and control costs so the project can be completed within the approved…