Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Creating Snake game in Turtle
Hello all,

I am creating a snake game with Python, in Turtle.
For this project, I am using this video:

The code I wrote is:

And the error I am getting is:
raise Terminator

I tried looking online but I couldn't find help.

BTW- I am not using Pygame on purpose, since I am still a beginner and I want to learn the "basics".

Thanks in advance for your reply!
Larz60+ wrote Feb-07-2019, 03:11 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
You don't ever move the object. Take a look at the goto() function in the docs. Also, your variables are local to the functions, so x, y, and head.direction are garbage collected when the function exits and so the code calling these functions never has access to any changes, i.e. if the object was moving, it would move to the same place; see this link on passing variable to, and returning them from a function A test program from my toolbox that could use some modifications
from turtle import *
from random import *
import time


maxx = 300
maxy = 250
minx= -maxx
miny= - maxy

title ("shooting ball")

bounce_point = 20

x = randint(minx + bounce_point, maxx + bounce_point)
y = randint(miny + bounce_point, maxy + bounce_point)


dx = 10
dy = 10
ctr = 0

while ctr < 200:  ## set a reasonable limit
    ctr += 1
    xx = x + dx

    ## test for sides of bounding box
    ## and reverse direction if found
    if xx < minx+bounce_point:
        xx = minx + bounce_point
        dx = -dx

    if xx > maxx - bounce_point:
        xx = maxx- bounce_point
        dx = -dx

    if yy < miny + bounce_point:
        yy= miny + bounce_point
        dy = -dy

    if xx > maxx - bounce_point:
        xx = maxx- bounce_point
        dx = -dx

    if yy < miny + bounce_point:
        yy= miny + bounce_point
        dy = -dy

    if yy > maxy + bounce_point:
        yy = maxy + bounce_point
        dy = -dy

    x = xx
    y = yy

    time.sleep(0.01)  ## allow time for a screen update 

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  [turtle]How would I create gravity? GalaxyCoyote 4 344 May-31-2019, 08:34 PM
Last Post: joe_momma
  [PyGame] Made my first Python program: Snake. Please help me improve it andrerocha1998 7 458 Feb-19-2019, 07:08 PM
Last Post: Windspar
  [PyGame] Game Logic problem with a "The Game of Life" Replication Coda 2 580 Dec-24-2018, 09:26 AM
Last Post: Coda
  [PyGame] Basic Snake game (using OOP) PyAlex 1 1,143 Sep-10-2018, 09:02 PM
Last Post: Mekire
  [PyGame] Snake not changing directions in Snake Game Bjdamaster 4 784 Aug-13-2018, 05:09 AM
Last Post: Bjdamaster
  [PyGame] Turtle and Pygame together cuevabros 4 1,379 Jun-27-2018, 03:04 PM
Last Post: cuevabros
  [PyGame] Snake controls not working jakegold98 5 1,318 Dec-12-2017, 01:45 AM
Last Post: Windspar
  Can't make the turtle walk.. Turry 3 1,480 Nov-26-2017, 05:05 PM
Last Post: heiner55

Forum Jump:

Users browsing this thread: 1 Guest(s)