Introducing Sammy the snake
Before we start making the Snake game, we need to set up our textures for the snake and the game play area. So, let's remove the default code from our GameScreen
class, leaving just our SpriteBatch
batch's clear screen calls:
public class GameScreen extends ScreenAdapter { private SpriteBatch batch; @Override public void show() { batch = new SpriteBatch(); } @Override public void render(float delta) { Gdx.gl.glClearColor(1, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); } }
Next, let's change the color that fills the screen from red to black. We can do this by updating the glClearColor
method call to reference the r, g
, b
, a
values of the black Color
class:
Gdx.gl.glClearColor(Color.BLACK.r, Color.BLACK.g, Color.BLACK.b, ...
Get LibGDX Game Development By Example now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.