Hello, my programm doesn't run and I don't find an answer
Skript:
function love.load ()
love.graphics.setBackgroundColor( 255, 255, 255)
-- Laden von Gegenständen
--Rechteck = love.graphics.newImage("Texturen/Rechteck.png") --Laden der Datei "Rechteck.png" welches in diesem fall ein Bild ist
--width = Rechteck:getWidth(50)
-- height = Rechteck:getHeight(20)
-- Rechteck1 = love.graphics.newImage("Texturen/Rechteck1.png")
-- width = Rechteck1:getWidth(20)
-- height = Rechteck1:getHeight(60)
-- Rechteck2 = love.graphics.newImage("Texturen/Rechteck2.png")
-- width = Rechteck2:getWidth(500)
-- height = Rechteck2:getHeight(20)
a=love.graphics.newImage("tilebild1.png")
b=love.graphics.newImage("tilebild2.png")
love.mouse.setVisible(true) -- standartmaus unsichtbar machen (false angeben) standartmaus sichtbar machen ( true angeben)
img = love.graphics.newImage("Texturen/mouse.png") -- laden eines eigenen Mauszeigers
end
map={
{a,a,a,a,a,b,a,a,a,b,a,a,a,b,a}, --Zeile 1
{b,a,a,a,a,a,a,a,a,a,a,a,a,b,a}, --Zeile 2
{a,a,b,a,a,b,a,a,a,a,a,b,a,b,a}, --Zeile 3
{a,a,a,a,a,a,a,a,a,a,a,a,a,b,a}, --Zeile 4
{a,a,b,a,a,b,a,a,a,a,a,b,a,b,a}, --Zeile 5
{a,a,a,b,a,a,a,a,a,b,a,a,a,b,a}, --Zeile 6
{a,b,a,a,a,b,a,b,a,a,a,b,a,b,a}, --Zeile 7
{a,a,a,b,a,a,a,b,a,a,b,a,a,b,a} --Zeile 8
}
while true do
for c=1,8 do
for d=1,15 do
screen:blit(a*32,b*32,map[a],false)
end
end
screen.flip()
screen.waitVblankStart()
end
function love.draw ()
--Mauskasten
-- local a = love.mouse.getX()
-- local b = love.mouse.getY()
-- love.graphics.setColor( 0, 0, 255, 255)
-- love.graphics.rectangle("fill", a-10, b-10, 20, 20)
end
function love.update (dt)
end
function love.focus(bool) --Maus im Spielbereich oder nicht!?
if bool then
print("Maus im Spielfenster!") --Maus im Spelbereich
else
print("Maus nicht im Spielfenster!") --Maus nicht im Spielbereich
end
end
function love.keypressed ( key, unicode) --In der Console wird angezeigt welche Taste zuletzt gedückt wurde
if tonumber(4) then -- if the key is numeric (0-9), execute the next line
love.mouse.setPosition(tonumber(4) * 10, love.mouse.getY()) -- multiply the key by 10 to make the effect more visible, maintain the Y position via getY
end
print("Es wurde gerade die Taste " .. key .. " gedrueckt")
end
function love.keyreleased( key, unicode)
end
function love.mousepressed( x, y, button)
print( x, y, button) --Schreibt in die Console
end
function love.mousereleased( x, y, butten)
end
function love.quit()
end
Need help...
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Need help...
Welcome.
First, you assign that table outside the love.load function. At that time, a and b are still nil.
Second, remove the while true loop. Because it runs forever, it means your game will never start.
Third, what are screen:blit(), screen.flip() and screen.waitVblankStart()? Are you using some sort of library? Because I see no call to require.
First, you assign that table outside the love.load function. At that time, a and b are still nil.
Second, remove the while true loop. Because it runs forever, it means your game will never start.
Third, what are screen:blit(), screen.flip() and screen.waitVblankStart()? Are you using some sort of library? Because I see no call to require.
Help us help you: attach a .love.
Re: Need help...
"First, you assign that table outside the love.load function"" so you mean a neu .txt data with the "map ={...}" ?
Second, remove the while true loop. That mean I must set the wihle false?
Is this right?:
while false do
for c=1,8 do
for d=1,15 do
screen:blit(a*32,b*32,map[a],false)
end
end
screen.flip()
screen.waitVblankStart()
end
Thanks for the fast answer!
Second, remove the while true loop. That mean I must set the wihle false?
Is this right?:
while false do
for c=1,8 do
for d=1,15 do
screen:blit(a*32,b*32,map[a],false)
end
end
screen.flip()
screen.waitVblankStart()
end
Thanks for the fast answer!
Re: Need help...
Rocks360 wrote:"First, you assign that table outside the love.load function"" so you mean a neu .txt data with the "map ={...}" ?
Second, remove the while true loop. That mean I must set the wihle false?
Is this right?:
while false do
for c=1,8 do
for d=1,15 do
screen:blit(a*32,b*32,map[a],false)
end
end
screen.flip()
screen.waitVblankStart()
end
Thanks for the fast answer!
No more like:
Code: Select all
for c = 1, #map do
for d = 1, #map[y] do
screen:blit(a*32,b*32,map[a][b],false)
end
end
screen.flip()
screen.waitVblankStart()
Also, can you post your .love hear?
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
personal page and a raycaster
Re: Need help...
Rocks, LÖVE isn't a LuaPlayer for PSP, you don't need to set the loop and to call screen:flip, screen.waitVblankStart and an image is printed with love.graphics.draw(image, x, y)... If there's more that you may want to ask... ask!
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
- Roland_Yonaba
- Inner party member
- Posts: 1563
- Joined: Tue Jun 21, 2011 6:08 pm
- Location: Ouagadougou (Burkina Faso)
- Contact:
Re: Need help...
These commands are used in most of Lua Players, frameworks which run Lua code on PSP. They are used for rendering update and graphical buffers...Robin wrote: Third, what are screen:blit(), screen.flip() and screen.waitVblankStart()? Are you using some sort of library? Because I see no call to require.
I guess Rocks360 used to code for PSP, and might be quite confused with Löve, actually.
@Rocks360 :
- first, wrap your snippets with code tags when posting...It makes the whole thread more readable.
- Second, you have to consider that the minimum code you did used with Lua Players is *NOT* valid with love. So when you write screen.flip(), screen.waitVblankStart(), it actually means nothing to Löve framework.
But, basically, Lua remains Lua, and Love runs Lua code, giving you additionnal commands for physics, playing souds, music, fonts, accessing mouse and keyboard, etc. So you won't get lost.
You should start reading these topics on the wiki : Getting Started, config files , love module and callbacks.
There are also plenty tutorials!
He just meant that all assignation before the main loop must be done inside love.load callback.Robin wrote: First, you assign that table outside the love.load function. At that time, a and b are still nil.
When Love runs, it executes first love.load, then the rest of the callbacks.
Yes, cause love.draw and love.update are equivalent to while true do...end you used to manipulate with other Lua Players.Robin wrote: Second, remove the while true loop. Because it runs forever, it means your game will never start.
Thus, you will have to put the update routines inside love.update, and the rendering routines inside love.draw. But don't use while true do...end
As an example, this:
Code: Select all
--Valid with Lua players
-- A simple square moving
local yellow = Color.new(255,255,0)
local square = {x = 0, y = 0, width = 100, height = 100}
local function drawSquare(s)
screen:fillRect(s.x,s.y,s.x+s.width,s.y+s.height, yellow)
end
while true do
local key = Controls.read()
if key:left() then s.x = s.x-1 end
if key:right() then s.x = s.x+1 end
if key:up() then s.y = s.t-1 end
if key:down() then s.y = s.y+1 end
drawSquare(s)
screen.waitVblankStart()
screen.flip()
end
Code: Select all
--Valid with Love
-- A simple square moving
function love.load()
yellow = {255,255,0}
--- square.speed can be modified to provide the accuracy that fits you.
square = {x = 0, y = 0, width = 100, height = 100, speed = 1}
function drawSquare(s, color)
love.graphics.setColor(color)
love.graphics.rectangle(s.x,s.y,s.width,s.height)
end
function squareUpdate(s,dt)
if love.keyboard.isDown("left") then s.x = s.x-s.speed*dt end
if love.keyboard.isDown("right") then s.x = s.x+s.speed*dt end
if love.keyboard.isDown("up") then s.y = s.y-s.speed*dt end
if love.keyboard.isDown("down") then s.y = s.y+s.speed*dt end
end
end
function love.update(dt)
squareUpdate(square,dt)
end
function love.draw()
drawsquare(square,yellow)
end
Hope this will help.
Who is online
Users browsing this forum: No registered users and 7 guests