ArrayList Of pictures for a snake game ?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Mi4_Slayer
Prole
Posts: 1
Joined: Thu Feb 16, 2017 7:47 pm

ArrayList Of pictures for a snake game ?

Post by Mi4_Slayer »

I am trying to make a snake game .... without the rectangle function. But most guide use rectangle. So I wanna know if I can make a array with pictures
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: ArrayList Of pictures for a snake game ?

Post by raidho36 »

Sure you can fill your grid with Image references. Then you draw the whole thing by iterating over each row in each column (or the other way around) and draw the Image in that grid cell. Just don't create new Images every time you change cell image, instead create your Images on load and then put references to those images into the grid.

Code: Select all

local image1 = love.graphics.newImage ( "snake123.png" )
--[[  ]]--
grid[ x ][ y ] = image1
--[[  ]]--
love.graphics.draw ( grid[ x ][ y ], xx, yy )
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 4 guests