mapping error

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
sparkeyus
Prole
Posts: 1
Joined: Sat Feb 15, 2014 11:31 pm

mapping error

Post by sparkeyus »

I have recently decided that it would be a really cool idea to learn code with Lua, and im loving it so far but i have run into some issues with either the code or the map size for my game.

I'm using löve 0.8.0 (I was using 0.9.0, the downgrade didn't change much).

so getting more to the point i have been following videos from goature on youtube and copied the code exact, even had to edit some code in the tile lua in the files linked in his description for https://www.youtube.com/watch?v=RCQouqjjBaU

so when i save my code and run the .bat file i get this

http://s41.photobucket.com/user/sean_fo ... a.png.html

when reallly the map is much bigger

http://s41.photobucket.com/user/sean_fo ... b.png.html


so if anyone could be really cool and let me know if its a code/engine error or wheter its me just me a f###ing idiot.

sean
notencore
Prole
Posts: 16
Joined: Wed Mar 13, 2013 6:08 pm

Re: mapping error

Post by notencore »

Hello!

Your mapping error is not an error at all, rather, the size of the map is larger than the size of the viewport.

Using

Code: Select all

love.graphics.push()
love.graphics.translate(x,y)
--drawing operations here
love.graphics.pop()
You can move what's being drawn on screen by translating it to the left or right. By defining two global variables viewPortX and viewPortY, then increasing/decreasing those by one or more whenever you get the appropriate love.keypressed() call, you can scroll around the map.

For example

Code: Select all

love.load = function()
  --map loading stuff here
  viewPortX = 0
  viewPortY = 0
end

love.update = function(dt)
  love.keypressed = function(key)
    if key == "up" then
      viewPortY = viewPortY - 16
    elseif key == "down" then
      viewPortY = viewPortY + 16
    elseif key == "left" then
      viewPortX = viewPortX -16
    elseif key == "right" then
      viewPortX = viewPortX + 16
    end
  end

--whatever other updates you need to perform go here
end

love.draw = function()
  love.graphics.push()
  love.graphics.translate(viewPortX, viewPortY)
  --draw things here
  love.graphics.pop()
end
This is a somewhat simplified example and not always appropriate for use in a real game, but should be fine for quick use.
nooblord
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests