first problem

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.
gagagott
Prole
Posts: 10
Joined: Thu Dec 11, 2008 8:55 pm

first problem

Post by gagagott »

hi,
I´m new here and i have an noob problem.
Why this code does´t work:

Code: Select all

function load()
end

function update(dt)
end

function draw()
   love.graphics.draw("hello world",100,100)
end
only a black window apperars. why?
User avatar
Merkoth
Party member
Posts: 186
Joined: Mon Feb 04, 2008 11:43 pm
Location: Buenos Aires, Argentina

Re: first problem

Post by Merkoth »

That's because you're not setting any font to draw text with. To solve this, you can use the default font:

Code: Select all

local font = love.graphics.newFont(love.default_font, 12) 
love.graphics.setFont(font) 
Or load your own:

Code: Select all

local font = love.graphics.newFont("Arial.ttf", 12) 
love.graphics.setFont(font) 
You can read a tutorial about fonts here and, of course, check the LÖVE docs for further details.

And welcome :)
gagagott
Prole
Posts: 10
Joined: Thu Dec 11, 2008 8:55 pm

Re: first problem

Post by gagagott »

oh thanks
gagagott
Prole
Posts: 10
Joined: Thu Dec 11, 2008 8:55 pm

Re: first problem

Post by gagagott »

ok, next question.xD
why this code doesn´t change from A to I

Code: Select all

------------------------------------------------------

function load()

--Player settings

  player_walk_timer=0
  player_skin='A'
  player_size=12
  player_walking=false
  player_font = love.graphics.newFont(love.default_font, player_size)


--Physical settings

  world = love.physics.newWorld(1000, 1000) 
  world:setGravity(0, 100) 

  ground = love.physics.newBody(world, 0, 0, 0)      
  ground_shape = love.physics.newRectangleShape(ground, 500, 490, 1000, 10)

  player=love.physics.newBody(world,100,100,10)
  player_csharp=love.physics.newCircleShape(player,player_size/2)
 

end

------------------------------------------------------

function update(dt)

  world:update(dt)
  
  if player_walk_timer>1 then
    player_walk_timer=0
    if (player_skin=='A') then
      plyer_skin='I'
    else
      player_skin='A'
    end  
  end

  player_walk_timer=player_walk_timer+dt

end

------------------------------------------------------

function draw()

love.graphics.setFont(player_font)
love.graphics.draw(player_skin,player:getX(),player:getY())
love.graphics.draw("player_walk_timer="..player_walk_timer,100,100)
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: first problem

Post by bartbes »

typo:

Code: Select all

plyer_skin='I'
should be

Code: Select all

player_skin='I'
gagagott
Prole
Posts: 10
Joined: Thu Dec 11, 2008 8:55 pm

Re: first problem

Post by gagagott »

oh thanks I´m a little bit messy.
gagagott
Prole
Posts: 10
Joined: Thu Dec 11, 2008 8:55 pm

Re: first problem

Post by gagagott »

I hope this is my last problem.xD
http://love2d.org/docs/Body_applyForce_2.html

what means offset?
User avatar
Merkoth
Party member
Posts: 186
Joined: Mon Feb 04, 2008 11:43 pm
Location: Buenos Aires, Argentina

Re: first problem

Post by Merkoth »

That is probably one of the most annoying things of Lua ^^

Edit: Argh. Replied to the wrong post X_X
User avatar
Merkoth
Party member
Posts: 186
Joined: Mon Feb 04, 2008 11:43 pm
Location: Buenos Aires, Argentina

Re: first problem

Post by Merkoth »

gagagott wrote:I hope this is my last problem.xD
http://love2d.org/docs/Body_applyForce_2.html

what means offset?
According to Box2D docs, the offset is the point (in world coordinates) where the force is applied, usually resulting in a torque about the center of mass of said body.

Just for the record: LÖVE's physics subsystem is based in an external library called Box2D, so most LÖVE physics-related methods have their Box2D counterpart, making the Box2D manual a handy tool when in doubt :)
gagagott
Prole
Posts: 10
Joined: Thu Dec 11, 2008 8:55 pm

Re: first problem

Post by gagagott »

Is there any easy way too look if the user click on a body of an image?
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], darkfrei, Google [Bot] and 3 guests