However, it seems like spritebatch is made even more specifically for this purpose, but I don't understand how it works. Is it a table that stores images as values?
Here's an example of the table I store all of my images in:
Code: Select all
images = {
world = {
tiles = {
earth = {
love.graphics.newImage("tiles/earth/1.png"),
love.graphics.newImage("tiles/earth/2.png"),
love.graphics.newImage("tiles/earth/3.png"),
love.graphics.newImage("tiles/earth/4.png"),
love.graphics.newImage("tiles/earth/loam.png"),
},
grass = {
meadow_foxtail = love.graphics.newImage("tiles/grass/meadow_foxtail.png"),
},
flowers = {
wild_lupin = love.graphics.newImage("tiles/flowers/wild_lupin.png"),
field_poppy = love.graphics.newImage("tiles/flowers/field_poppy.png"),
},
trees = {
red_maple = {love.graphics.newImage("tiles/trees/saplings/red_maple.png"),
love.graphics.newImage("tiles/trees/trunks/red_maple.png"),
love.graphics.newImage("tiles/trees/leaf cover/red_maple.png"), },
}
},
items = {
natural = {
seeds = {
--grass
meadow_foxtail = love.graphics.newImage("tiles/items/seed_meadowfoxtail.png"),
--flowers
wild_lupin = love.graphics.newImage("tiles/items/seed_wildlupin.png"),
field_poppy = love.graphics.newImage("tiles/items/seed_fieldpoppy.png"),
--trees
red_maple = love.graphics.newImage("tiles/items/seed_redmaple.png"),
},
},
},
player = {
idle = {
down = newAnimation(love.graphics.newImage( "tiles/character/idle_down.png" ), 25, 50, 0.1, 0),
up = newAnimation(love.graphics.newImage( "tiles/character/idle_up.png" ), 25, 50, 0.1, 0),
right = newAnimation(love.graphics.newImage( "tiles/character/idle_right.png" ), 25, 50, 0.1, 0),
left = newAnimation(love.graphics.newImage( "tiles/character/idle_left.png" ), 25, 50, 0.1, 0),
},
walk = {
right = newAnimation(love.graphics.newImage( "tiles/character/walk_right.png" ), 25, 50, 0.1, 0),
left = newAnimation(love.graphics.newImage( "tiles/character/walk_left.png" ), 25, 50, 0.1, 0),
up = newAnimation(love.graphics.newImage( "tiles/character/walk_up.png" ), 25, 50, 0.1, 0),
down = newAnimation(love.graphics.newImage( "tiles/character/walk_down.png" ), 25, 50, 0.1, 0),
},
},
},
hud = {
main = {
bar = love.graphics.newImage("tiles/hud/hud_bar.png"),
},
windows = {
context_window = love.graphics.newImage("tiles/hud/hud_context.png"),
examine_window = love.graphics.newImage("tiles/hud/hud_examine.png"),
help_window = love.graphics.newImage("tiles/hud/help_window.png"),
inventory_window = love.graphics.newImage("tiles/hud/inventory_window_2.png"),
inventory_window_info = love.graphics.newImage("tiles/hud/hud_inventory_info.png"),
},
buttons = {
examine = love.graphics.newImage("tiles/hud/button_examine.png"),
inventory = love.graphics.newImage("tiles/hud/button_inventory.png"),
help = love.graphics.newImage("tiles/hud/button_help.png"),
nextgen = love.graphics.newImage("tiles/hud/hud_newgen.png"),
close = love.graphics.newImage("tiles/hud/close.png"),
inventory_slot = love.graphics.newImage("tiles/hud/inventory_slot_1.png"),
inventory_action = love.graphics.newImage("tiles/hud/hud_inventory_action.png"),
context_item = love.graphics.newImage("tiles/hud/hud_context_itemslot.png"),
context_action = love.graphics.newImage("tiles/hud/hud_action_itemslot.png"),
},
boxes = {
inventory_main = love.graphics.newImage("tiles/hud/hud_inventorytextbox.png"),
inventory_grid = love.graphics.newImage("tiles/hud/hud_inventorygrid.png"),
},
menus = {
menu_action = love.graphics.newImage("tiles/hud/menu_actions.png"),
},
items = {
natural = {
seeds = {
--grass
meadow_foxtail = love.graphics.newImage("tiles/grass/icons/seed_meadowfoxtail.png"),
--flowers
wild_lupin = love.graphics.newImage("tiles/flowers/icons/seed_wildlupin.png"),
field_poppy = love.graphics.newImage("tiles/flowers/icons/seed_fieldpoppy.png"),
--trees
red_maple = love.graphics.newImage("tiles/trees/icons/seed_redmaple.png"),
},
},
},
},
cursors = {
default = love.graphics.newImage("tiles/cursors/crs_default.png"),
tileselect = love.graphics.newImage("tiles/cursors/crs_tileselect.png"),
},
}