Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
The Sweet Temptation of Fruit | Building a Classic Snake Game
Building a Classic Snake Game
course content

Conteúdo do Curso

Building a Classic Snake Game

The Sweet Temptation of Fruit

Before bringing our digital serpent to life, we must ensure that it has something to feast upon. In this chapter, we introduce the concept of fruit scattered across the game area, waiting to be devoured.

apple

Let's think about what our fruit buddy should have. It needs a cozy spot to grow (field), a unique look or symbol to stand out from the crowd (sprite), and we should always know where to find it(position). Let's organize them neatly into a table.

Aspect
Description
Growing EnvironmentRequires a cozy spot to thrive (field)
Appearance/SymbolShould possess a unique look or symbol (sprite)
Location AwarenessWe need to know its whereabouts consistently (position)

The field will be represented by a tuple. Keep in mind that the first element of the tuple indicates the x position, while the second element indicates the y position.

Note

Sprite is a two-dimensional representation of objects, in this context fruit. Without libraries or frameworks, we'll represent sprites using symbols instead of images, simplifying the concept.

Tarefa

  • Create a Fruit class.
  • Add a constructor that will take a game field and sprite(symbol to represent fruit) as a parameters.
  • Set the position to the right down corner of the field.

Tarefa

  • Create a Fruit class.
  • Add a constructor that will take a game field and sprite(symbol to represent fruit) as a parameters.
  • Set the position to the right down corner of the field.

Mark tasks as Completed
Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo

Tudo estava claro?

Before bringing our digital serpent to life, we must ensure that it has something to feast upon. In this chapter, we introduce the concept of fruit scattered across the game area, waiting to be devoured.

apple

Let's think about what our fruit buddy should have. It needs a cozy spot to grow (field), a unique look or symbol to stand out from the crowd (sprite), and we should always know where to find it(position). Let's organize them neatly into a table.

Aspect
Description
Growing EnvironmentRequires a cozy spot to thrive (field)
Appearance/SymbolShould possess a unique look or symbol (sprite)
Location AwarenessWe need to know its whereabouts consistently (position)

The field will be represented by a tuple. Keep in mind that the first element of the tuple indicates the x position, while the second element indicates the y position.

Note

Sprite is a two-dimensional representation of objects, in this context fruit. Without libraries or frameworks, we'll represent sprites using symbols instead of images, simplifying the concept.

Tarefa

  • Create a Fruit class.
  • Add a constructor that will take a game field and sprite(symbol to represent fruit) as a parameters.
  • Set the position to the right down corner of the field.

Mark tasks as Completed
Mude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Seção 1. Capítulo 2
AVAILABLE TO ULTIMATE ONLY
We're sorry to hear that something went wrong. What happened?
some-alt