deepan marappan’s Post

View profile for deepan marappan, graphic

Aspiring Frontend Developer |👨💻 Seeking a Entry-Level SDE position | 💻Creating Immersive Web Experiences with HTML, CSS, and JavaScript | Transforming Concepts into Interactive Reality

Hello Everyone 👋 Today is my Day 2️⃣1️⃣ of my #100daysofcodingchallenge👨💻 to learn python zero 0️⃣ to mastery 🏆level In this day I was completed my Snake game🎮 project project link : https://lnkd.in/gmH63MaD following steps to complete this snake 🐍game 🕹project 💻 ✔ Create a game background ✔Create a snake body ✔Move the snake ✔Control the movement snake 📌Detect collision with food 📌Create a score board💰 📌Detect collision with wall 📌Detect collision with own tail 📌Extend tail collision Then using OOPs concepts for clean and understandable code I use "Inheritance" concepts in this game, So I was create two more classes - scoreboard, food ✔Detect collision with food I import "turtle package" as super class 🕷 for food class(sub class)🕸 . Using "turtle🐢 package" I can create a shape of food, food size, color of food and after eat the food it again generate food in random place in game area. Using this random process I was import "random package". Using this random package I set random x axis and random y axis to the food class, those random x and random y those are implemented in "goto(random x, random y)" function and food is change place after snake🐍 eat. ✔Create a score board💰 After snake ate food then show the score of snake ate food count this process was created using a "scoreboard" class. Same as "food" class, I import the "turtle" package to create a scoreboard. Turtle package is a superclass🕷 and scoreboard is a subclass🕸using turtle I created a "scoreboard" class and choose it's color, alignment area, font type and its size also can create using the turtle package's write() function then using goto( ) function score was fixed top of the play screen area when snake eat food then the score was updated. ✔ Detect collision with own tail In the game when snake was collision with wall and also its own tail then this game was over. ✔ Detect collision with wall Initially I was programmed when the snake is hits wall then the game is over. In snake class when the snake head was touch the wall then game was over. It make by the size of game screen was used, In case of the snake head was touch the end of screen(wall) this game was over. I use xcor() and ycor() function with screen height as y and width as x. If snake head exceed the wall then the game was over. If its over I used scoreboard class and apply write() function to make "game over" title to show whem the game completed ✔Extend tail collision After snake was ate food then increase its tail. so I use "snake" class to increase size of tail when the food was ate. so I create a add_segment() and extend() function in snake class. Finally I was done the last things that was detect collision with own tail using "python tuple" method. when the snake head was met with it's own tail then game was over after that the screen was show Game over. ‼ 🏆 link🔗 to play 🕹 my game 👇 game link🔗 : https://lnkd.in/gmH63MaD

day 21

day 21

https://www.replit.com

To view or add a comment, sign in

Explore topics