Hallo Leute ich habe seit Gestern mit Lua und Love2D Angefangen, nun Habe ich 3 Lua Dateien; main.lua, cloud.lua, conf.lua
In der main.lua Lade ich ein Hamster Bild und füge dort die Steuerung ein Code;
|
Quellcode
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
function love.load()
hamster = love.graphics.newImage("hamster.png")
x = 50
y = 50
speed = 400
end
function love.update(dt)
if love.keyboard.isDown("right") then
x = x + (speed * dt)
elseif love.keyboard.isDown("left") then
x = x - (speed * dt)
end
if love.keyboard.isDown("down") then
y = y + (speed * dt)
elseif love.keyboard.isDown("up") then
y = y - (speed * dt)
end
end
function love.draw()
love.graphics.draw(hamster, x, y)
end
|
In der cloud.lua Male ich 2 Rectangles die sich überschneiden um Wolken darzustellen Code;
|
Quellcode
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
function love.draw()
draw_clouds()
end
function draw_cloud_left()
love.graphics.setColor(183, 183, 183)
love.graphics.rectangle("fill", 80, 87, 256, 98)
love.graphics.rectangle("fill", 232, 128, 256, 98)
love.graphics.setColor(255, 255, 255)
end
function draw_cloud_right()
end
function draw_clouds()
draw_cloud_left()
draw_cloud_right()
end
|
Und in der conf.lua Befinden sich Einstellungen zum Fenster etc. Code;
|
Quellcode
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
function love.conf(t)
t.modules.joystick = true -- Enable the joystick module (boolean)
t.modules.audio = true -- Enable the audio module (boolean)
t.modules.keyboard = true -- Enable the keyboard module (boolean)
t.modules.event = true -- Enable the event module (boolean)
t.modules.image = true -- Enable the image module (boolean)
t.modules.graphics = true -- Enable the graphics module (boolean)
t.modules.timer = true -- Enable the timer module (boolean)
t.modules.mouse = true -- Enable the mouse module (boolean)
t.modules.sound = true -- Enable the sound module (boolean)
t.modules.thread = true
t.modules.physics = true -- Enable the physics module (boolean)
t.console = true -- Attach a console (boolean, Windows only)
t.title = "Love 2D Learning" -- The title of the window the game is in (string)
t.author = "Pigz" -- The author of the game (string)
t.screen.fullscreen = false -- Enable fullscreen (boolean)
t.screen.vsync = false -- Enable vertical sync (boolean)
t.screen.fsaa = 0 -- The number of FSAA-buffers (number)
t.screen.height = 600 -- The window height (number)
t.screen.width = 800 -- The window width (number)
end
|
Nun möchte ich das die cloud.lua im Fenster gemalt wird was aber nicht Passiert. Was kann ich tun damit dies Passiert? (Die cloud.lua Soll aber erhalten und Benutzt werden)