Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tutorial file with correct function calls #258

Merged
merged 1 commit into from
Mar 27, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 7 additions & 18 deletions tutorials/01-introduction-to-sti.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ function love.load()
end
```

Cool, we can now move our player around the screen! But that's only half the battle. We also want to centre the player in the screen so that the player never runs away from us. Instead, we want the world to move around our player. How do we accomplish this? LÖVE provides graphics transform tools such as `translate`, `rotate`, and `scale` that will give us the illusion that our player is static and the world is dynamic, instead of the other way around.
Cool, we can now move our player around the screen! But that's only half the battle. We also want to centre the player in the screen so that the player never runs away from us. Instead, we want the world to move around our player. How do we accomplish this? You can provide arguments to STI's `map.draw` to scale and translate the world. First two arguments are the translation and third and fourth are the scale.

```lua
function love.draw()
Expand All @@ -239,11 +239,8 @@ function love.draw()
local tx = math.floor(player.x - love.graphics.getWidth() / 2)
local ty = math.floor(player.y - love.graphics.getHeight() / 2)

-- Transform world
love.graphics.translate(-tx, -ty)

-- Draw world
map:draw()
-- Draw world with translation
map:draw(-tx, -ty)
end
```

Expand All @@ -263,12 +260,8 @@ function love.draw()
local tx = math.floor(player.x - screen_width / 2)
local ty = math.floor(player.y - screen_height / 2)

-- Transform world
love.graphics.scale(scale)
love.graphics.translate(-tx, -ty)

-- Draw world
map:draw()
-- Draw world with translation and scaling
map:draw(-tx, -ty, scale)
end
```

Expand Down Expand Up @@ -371,12 +364,8 @@ function love.draw()
local tx = math.floor(player.x - screen_width / 2)
local ty = math.floor(player.y - screen_height / 2)

-- Transform world
love.graphics.scale(scale)
love.graphics.translate(-tx, -ty)

-- Draw world
map:draw()
-- Draw world with translation and scaling
map:draw(-tx, -ty, scale)
end
```

Expand Down