i might need help as a new love2d user

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
justthoseguys12
Prole
Posts: 13
Joined: Fri Nov 22, 2024 7:18 pm

i might need help as a new love2d user

Post by justthoseguys12 »

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++)
:neko: :neko: :neko: :neko: :neko: :neko: :neko: :neko: :neko: :neko: :neko: :3 :neko: :neko: :neko: :neko: :neko: :neko: :neko: :3 :neko: :neko: :neko: :neko: :neko: :neko: :neko: :neko: :neko:
User avatar
justthoseguys12
Prole
Posts: 13
Joined: Fri Nov 22, 2024 7:18 pm

Re: i might need help as a new love2d user

Post by justthoseguys12 »

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
Attachments
main.love
(65.39 KiB) Downloaded 63 times
:neko: :neko: :neko: :neko: :neko: :neko: :neko: :neko: :neko: :neko: :neko: :3 :neko: :neko: :neko: :neko: :neko: :neko: :neko: :3 :neko: :neko: :neko: :neko: :neko: :neko: :neko: :neko: :neko:
User avatar
pgimeno
Party member
Posts: 3672
Joined: Sun Oct 18, 2015 2:58 pm

Re: i might need help as a new love2d user

Post by pgimeno »

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:

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
But it's also OK to place all asset loading inside love.load():

Code: Select all


function love.load()
  -- Load graphics
  whale = love.graphics.newImage("whale.jpg")

  -- Load audio
  src1 = love.audio.newSource("wow.mp3", "static")
end
Also, please use [code] ... [/code] tags to paste code snippets, as I did above; it will help us read your code better.
User avatar
Divinity
Prole
Posts: 7
Joined: Thu Nov 21, 2024 2:23 pm
Location: Portugal

Re: i might need help as a new love2d user

Post by Divinity »

I think you forgot

Code: Select all

src1:play()
after creating the sound
Last edited by Divinity on Sat Nov 23, 2024 12:49 am, edited 1 time in total.
poof()
User avatar
justthoseguys12
Prole
Posts: 13
Joined: Fri Nov 22, 2024 7:18 pm

Re: i might need help as a new love2d user

Post by justthoseguys12 »

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
:neko: :neko: :neko: :neko: :neko: :neko: :neko: :neko: :neko: :neko: :neko: :3 :neko: :neko: :neko: :neko: :neko: :neko: :neko: :3 :neko: :neko: :neko: :neko: :neko: :neko: :neko: :neko: :neko:
User avatar
justthoseguys12
Prole
Posts: 13
Joined: Fri Nov 22, 2024 7:18 pm

Re: i might need help as a new love2d user

Post by justthoseguys12 »

by that i mean i would like to know how to move the images not for people to do the entire process
:neko: :neko: :neko: :neko: :neko: :neko: :neko: :neko: :neko: :neko: :neko: :3 :neko: :neko: :neko: :neko: :neko: :neko: :neko: :3 :neko: :neko: :neko: :neko: :neko: :neko: :neko: :neko: :neko:
User avatar
pgimeno
Party member
Posts: 3672
Joined: Sun Oct 18, 2015 2:58 pm

Re: i might need help as a new love2d user

Post by pgimeno »

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.
RNavega
Party member
Posts: 385
Joined: Sun Aug 16, 2020 1:28 pm

Re: i might need help as a new love2d user

Post by RNavega »

On the DVD bouncing thing: it's probably the same behavior as the little ball from Pong.

e3c6c5fc9add528.gif
e3c6c5fc9add528.gif (106.53 KiB) Viewed 1092 times

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
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 12 guests