Page 2 of 3

Re: still noob and going to learn :)

Posted: Sat Dec 10, 2016 4:46 pm
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

Re: still noob and going to learn :)

Posted: Sat Dec 10, 2016 4:52 pm
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

Re: still noob and going to learn :)

Posted: Sat Dec 10, 2016 5:01 pm
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

Re: still noob and going to learn :)

Posted: Sat Dec 10, 2016 5:07 pm
by pedrosgali
All the code is in the .love, unzip it and take a look. :)

Re: still noob and going to learn :)

Posted: Sat Dec 10, 2016 5:19 pm
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

Re: still noob and going to learn :)

Posted: Sun Dec 11, 2016 12:29 am
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


Re: still noob and going to learn :)

Posted: Sun Dec 11, 2016 9:54 am
by yogib33r
hello beeltz and thanx a lot :)
i go learn this afternoon :) thanx for source
regards

Re: still noob and going to learn :)

Posted: Sun Dec 11, 2016 2:23 pm
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

Re: still noob and going to learn :)

Posted: Sun Dec 11, 2016 7:12 pm
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

Re: still noob and going to learn :)

Posted: Sun Dec 11, 2016 8:07 pm
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!