i might need help as a new love2d user
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- justthoseguys12
- Prole
- Posts: 13
- Joined: Fri Nov 22, 2024 7:18 pm
i might need help as a new love2d user
I would like help along the way as a new love2d user just incase i cant figure out stuff on my own (i am using n++)
- justthoseguys12
- Prole
- Posts: 13
- Joined: Fri Nov 22, 2024 7:18 pm
Re: i might need help as a new love2d user
this is the code i have right now and i cant get the sound to load here is the code and i have the file as well
function love.load()
whale = love.graphics.newImage("whale.jpg")
end
function love.draw()
love.graphics.draw(whale, 300, 200)
end
function love.load()
src1 = love.audio.newSource("wow.mp3", "static")
end
function love.load()
whale = love.graphics.newImage("whale.jpg")
end
function love.draw()
love.graphics.draw(whale, 300, 200)
end
function love.load()
src1 = love.audio.newSource("wow.mp3", "static")
end
- Attachments
-
- main.love
- (65.39 KiB) Downloaded 63 times
Re: i might need help as a new love2d user
Don't create multiple love.load() functions, as each definition will overwrite the previous one and only the last one will prevail. Use a single love.load() function; if you want to split it into other functions, define them each with its own name, and call them from love.load().
For example:
But it's also OK to place all asset loading inside love.load():
Also, please use [code] ... [/code] tags to paste code snippets, as I did above; it will help us read your code better.
For example:
Code: Select all
local function loadGraphics()
whale = love.graphics.newImage("whale.jpg")
end
local function loadAudio()
src1 = love.audio.newSource("wow.mp3", "static")
end
function love.load()
loadGraphics()
loadAudio()
end
Code: Select all
function love.load()
-- Load graphics
whale = love.graphics.newImage("whale.jpg")
-- Load audio
src1 = love.audio.newSource("wow.mp3", "static")
end
Re: i might need help as a new love2d user
I think you forgot
after creating the sound
Code: Select all
src1:play()
Last edited by Divinity on Sat Nov 23, 2024 12:49 am, edited 1 time in total.
poof()
- justthoseguys12
- Prole
- Posts: 13
- Joined: Fri Nov 22, 2024 7:18 pm
Re: i might need help as a new love2d user
can you help i would like for the 3 images I have to bounce around like the DVD logo I have the code and the file
Code: Select all
function love.load()
whale = love.graphics.newImage("whale.jpg")
wow = love.audio.newSource("wow.mp3", "static")
follow = love.graphics.newImage("follow.png")
gofollow = love.graphics.newImage("Go follow.png")
love.window.setFullscreen(true, "desktop")
end
function love.draw()
love.graphics.draw(whale, 300, 200)
love.graphics.draw(follow, 200, 500)
love.graphics.draw(gofollow, 200, 100)
end
function love.update(dt)
if not wow:isPlaying( ) then
love.audio.play( wow )
end
end
function love.keypressed(key, scancode, isrepeat)
if key == "escape" then
love.event.quit()
end
end
- Attachments
-
- main.love
- (164.92 KiB) Downloaded 61 times
- justthoseguys12
- Prole
- Posts: 13
- Joined: Fri Nov 22, 2024 7:18 pm
Re: i might need help as a new love2d user
by that i mean i would like to know how to move the images not for people to do the entire process
Re: i might need help as a new love2d user
I think you need some sort of introduction to programming. The freely available book "Programming in Lua" might be a good one to learn the basics.
Learning programming is out of scope for this forum, so I'll give you a hint in this case but I won't intervene again if you have further basic programming questions. You currently have the coordinates in fixed positions, like 300, 200 etc.; if you want to move an object, what you need is to store these coordinates in variables so that they can be different every frame; that's how you make moving objects. Then in the love.update function you change these variables according to the movement you want to apply to them. In the DVD logo case, you have to increase or decrease them every frame, always within the limits of the screen.
Learning programming is out of scope for this forum, so I'll give you a hint in this case but I won't intervene again if you have further basic programming questions. You currently have the coordinates in fixed positions, like 300, 200 etc.; if you want to move an object, what you need is to store these coordinates in variables so that they can be different every frame; that's how you make moving objects. Then in the love.update function you change these variables according to the movement you want to apply to them. In the DVD logo case, you have to increase or decrease them every frame, always within the limits of the screen.
Re: i might need help as a new love2d user
On the DVD bouncing thing: it's probably the same behavior as the little ball from Pong.
So if your search for Pong tutorials (even if it's for some other engine than LÖVE) you can use it for that.
There are some tutorials on YouTube, but there's also this sample code called PÖNG:
https://gist.github.com/josefnpat/a1abc49d7badcfb42d75
So if your search for Pong tutorials (even if it's for some other engine than LÖVE) you can use it for that.
There are some tutorials on YouTube, but there's also this sample code called PÖNG:
https://gist.github.com/josefnpat/a1abc49d7badcfb42d75
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 12 guests