Du bist nicht angemeldet.

Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!

Werbeanzeige

1

05.04.2012, 16:00

Lua Verschiedene Dateien

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)

drakon

Supermoderator

Beiträge: 6 513

Wohnort: Schweiz

Beruf: Entrepreneur

  • Private Nachricht senden

2

05.04.2012, 17:41

Ich kenne mich mit Love2D jetzt nicht so aus, aber musst du die Dateien nicht noch irgendwie includen? Also bei Corona muss man explizit ein require benutzen, um andere Dateien einzubinden. Schau ev. mal da bei einem Tutorial oder so nach.

3

05.04.2012, 18:11

Werd ich machen! aber was ist Corona?

drakon

Supermoderator

Beiträge: 6 513

Wohnort: Schweiz

Beruf: Entrepreneur

  • Private Nachricht senden

4

05.04.2012, 18:17

Ein Framework für mobile Apps. Baut auch auf Lua auf.

Siehe hier:
http://www.anscamobile.com/corona/

5

05.04.2012, 18:24

Hab ich mir mal Angeschaut damt schreibt man Apps für iPhone usw.

drakon

Supermoderator

Beiträge: 6 513

Wohnort: Schweiz

Beruf: Entrepreneur

  • Private Nachricht senden

Werbeanzeige