still noob and going to learn :)

General discussion about LÖVE, Lua, game development, puns, and unicorns.
pedrosgali
Party member
Posts: 107
Joined: Wed Oct 15, 2014 5:00 pm
Location: Yorkshire, England

Re: still noob and going to learn :)

Post by pedrosgali »

It seems I can't put an attachment on a PM so here is a .love with the working shader, use WASD to move the stars.

If you unzip it and check the main.lua you can see how to get it working in your program, playing with the variables will get a more custom movement style. Hope this helps.
Starfield.love

Code: Select all

if not wearTheseGlasses() then
  chewing_on_trashcan = true
end
User avatar
yogib33r
Prole
Posts: 23
Joined: Thu Oct 17, 2013 6:30 pm
Location: dijon
Contact:

Re: still noob and going to learn :)

Post by yogib33r »

hello pedrogal

thanx a lot :) i go test and read it in the minutes coming.
i started to take informations in the sheepolution website and saw how it is simple to move a rectangle with a little code :) i have to test it tomorrow or before
thanx a lot i go test it right now

regards
User avatar
yogib33r
Prole
Posts: 23
Joined: Thu Oct 17, 2013 6:30 pm
Location: dijon
Contact:

Re: still noob and going to learn :)

Post by yogib33r »

ok i saw it and apart the stars (perhaps it is a bitmap "texture" done with plenty of random points ?) i can understand the way you done it. si move the stars with the command in love to move by keyboard. ok :) could you please give me the source ? i go tomorrow test the rectangle to move by keyboard and then we'll see :) i have to learn smoothly :)

thanx a lot yet

regards
pedrosgali
Party member
Posts: 107
Joined: Wed Oct 15, 2014 5:00 pm
Location: Yorkshire, England

Re: still noob and going to learn :)

Post by pedrosgali »

All the code is in the .love, unzip it and take a look. :)

Code: Select all

if not wearTheseGlasses() then
  chewing_on_trashcan = true
end
User avatar
yogib33r
Prole
Posts: 23
Joined: Thu Oct 17, 2013 6:30 pm
Location: dijon
Contact:

Re: still noob and going to learn :)

Post by yogib33r »

hello my dear new friend

i begin to mistake but i' m a noob ^^

here some bad script done, and no result

Code: Select all

function love.load()

end

function love.update(dt)
    x = x + 5 * dt
end

function love.draw()

end
function love.load()
    x = 100 
end

function love.draw()
    love.graphics.rectangle("line", x, 50, 200, 150)
end

love.draw()
ok i go see ! thanx a lot
User avatar
Beelz
Party member
Posts: 234
Joined: Thu Sep 24, 2015 1:05 pm
Location: New York, USA
Contact:

Re: still noob and going to learn :)

Post by Beelz »

To start, you have declared love.load and love.draw twice each. Also, you called love.draw manually at the end of the file, which just calls the function once when the file first initializes. Here's a quick example:

Code: Select all

function love.load()
	-- Create a "player" table
	player = {
		x = 300,
		y = 300,
		w = 50,
		h = 100,
		speed = 100
	}
end

local keyDown = love.keyboard.isDown

function love.update(dt)
   	-- Left <> Right
   	if keyDown('a') then
     	 	player.x = player.x - player.speed * dt
   	elseif keyDown('d') then
      		player.x = player.x + player.speed * dt
   	end
   
   	-- Up <> Down
   	if keyDown('w') then
      		player.y = player.y - player.speed * dt
   	elseif keyDown('s') then
      		player.y = player.y + player.speed * dt
   	end
end

function love.draw()
   	love.graphics.rectangle('fill', player.x, player.y, player.w, player.h)
end

Code: Select all

if self:hasBeer() then self:drink()
else self:getBeer() end
GitHub -- Website
User avatar
yogib33r
Prole
Posts: 23
Joined: Thu Oct 17, 2013 6:30 pm
Location: dijon
Contact:

Re: still noob and going to learn :)

Post by yogib33r »

hello beeltz and thanx a lot :)
i go learn this afternoon :) thanx for source
regards
User avatar
yogib33r
Prole
Posts: 23
Joined: Thu Oct 17, 2013 6:30 pm
Location: dijon
Contact:

Re: still noob and going to learn :)

Post by yogib33r »

ys it works fine ! so with the starfield i will give a vertical way, the rectangle i can change for a sprite i think i will have the way to do a cool intro ! i go learn more and show you in date and time "my" compilation of this
thanx a lot
User avatar
yogib33r
Prole
Posts: 23
Joined: Thu Oct 17, 2013 6:30 pm
Location: dijon
Contact:

Re: still noob and going to learn :)

Post by yogib33r »

hello all
me back again
so if i understand, no need to call the fonction() at the end of the scrip ? only make a love.draw() with a cool with the other functions ?
tell me what i go see how to work with tomorrow

regards to all, this forum is great and i'm happy to meet you and/with your cool sympaty

stéphane
User avatar
Beelz
Party member
Posts: 234
Joined: Thu Sep 24, 2015 1:05 pm
Location: New York, USA
Contact:

Re: still noob and going to learn :)

Post by Beelz »

The game loop works(usually behind the scenes) using love.run. This is generally how it works:

Code: Select all

-- Read and run whatever isn't in a function top to bottom
local a = 1

-- Including if you invoke a function(note that the function is called after it is declared)
function hello()
	print('Hello!')
end
hello()

-- Then run love.load
function love.load()
end

-- Then loop back and forth between love.update and love.draw (the loop)
function love.update(dt)
end

function love.draw()
end
There are also other callbacks to handle keyboard, mouse, etc, all in the wiki. I'm telling you, that wiki will be your best friend. Take your time reading it, it's very well documented!

Code: Select all

if self:hasBeer() then self:drink()
else self:getBeer() end
GitHub -- Website
Post Reply

Who is online

Users browsing this forum: No registered users and 98 guests