Snake via Python Turtle

  Рет қаралды 102

Zheng Li

Zheng Li

Күн бұрын

The pathfinding algorithm is A*.
A wonderful tutorial about A* can be found at www.redblobgam...
BGM: Shadow of the Ninja (NES) Music - Stage 1

Пікірлер: 1
@zhengli2589
@zhengli2589 2 жыл бұрын
I strongly suggest everyone to try this optional Task for fun: Moving a black square around. Please refer to the demo in the lecture video and try to move the black (or different color) square along different directions. You may imagine this optional task in the context of this game Snake. But you are developing a never-growing snake. Moving a black square is actually changing colors of different squares on a map. As the first step, you may try to make the same square “flash”, i.e. changing the color of the same square. Please read and copy the following code of flashing a square to play a bit. Then try to “move” the square by yourself. # Flashing a square import time import turtle turtle.TurtleScreen._RUNNING = True turtle.tracer(0, 0) myPen=turtle.Turtle() int_edge = 20 # Ten times flashing for i in range(10): # Start drawing a square in black myPen.begin_fill() myPen.penup() myPen.goto(0,0) # Go to a particular position as the bottom left corner of the square myPen.fillcolor("black") myPen.pendown() # Drawing four edges of the square for k in range(4): myPen.forward(int_edge) myPen.left(90) myPen.end_fill() turtle.update() # Finish drawing the square in black time.sleep(0.5) # Start drawing a square in white myPen.begin_fill() myPen.penup() myPen.goto(0,0) # Go to a particular position as the bottom left corner of the square myPen.fillcolor("white") myPen.pendown() # Drawing four edges of the square for k in range(4): myPen.forward(int_edge) myPen.left(90) myPen.end_fill() turtle.update() # Finish drawing the square in white time.sleep(0.5) myScreen = turtle.Screen() myScreen.exitonclick()
Game of Life via Python Turtle
2:41
Zheng Li
Рет қаралды 154
Get 10 Mega Boxes OR 60 Starr Drops!!
01:39
Brawl Stars
Рет қаралды 19 МЛН
Zombie Boy Saved My Life 💚
00:29
Alan Chikin Chow
Рет қаралды 27 МЛН
City Walk - Concepción -  Saturday Market
20:46
Zheng Li
Рет қаралды 6
City Walk - Concepción - My favourite two supermarkets
23:49
Chaos Game via Python Turtle
4:31
Zheng Li
Рет қаралды 169
I streamed until I beat Gravity Chess. It was ridiculous.
39:35
Green Lemon Games
Рет қаралды 189
City Walk - Concepción - Parque Ecuador
21:35
Zheng Li
Рет қаралды 46
Test Cycles Render | Blender 4.0
2:52
supartwi
Рет қаралды 27
Get 10 Mega Boxes OR 60 Starr Drops!!
01:39
Brawl Stars
Рет қаралды 19 МЛН