Hello and Questions!

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
LÖVER
Prole
Posts: 10
Joined: Mon Jan 05, 2009 9:09 pm

Hello and Questions!

Post by LÖVER » Mon Jan 05, 2009 9:21 pm

Hello everyone, first post here so I guess you need some kind of introduction...

Well, I'm currently 18 years old and am in my third quarter of my game design degree. I plan on specializing in game programming/game engine programming.

I have not used math at all for about 6-8 months, so I am kind of rusty so bear with me. I want to "shoot" a sprite at the mouse and I cannot for the life of me tell if it is working or not because it is going so freakin' fast! So, how do I slow down this and is this equation even correct to shoot a sprite at the mouse? The sprite should not follow the mouse, but shoot past it.

Code: Select all

function draw()   
   mouseY = love.mouse.getY()
   mouseX = love.mouse.getX()
   xDis = x - mouseX
   yDis = y - mouseY
   -- Subtract 90 because of odd default sprite angle starting at 0.
   rot = math.atan2(yDis, xDis) * (180 / math.pi) - 90
   
   if shootBullet == true then
      love.graphics.draw(bullet, posX, posY, rot)
      posX = posX - (mouseX - math.cos(rot))
      posY = posY - (mouseY - math.sin(rot))
   end
end
I love LOVE so far, fairly simplistic compared to some stuff I use in school, but debugging it is a pain! I hate dragging and dropping the folder onto Love.exe is there an easier way? I would love if I could push Debug in Visual Studio and have it do that for me, is that even possible? LOVE has also inspired me to learn Lua, as well and I must say... it's so hard to script in it when using C# or C++ in school all day. I find a lot of { } and ; in my Lua :)

Keep up the good work! I plan on pumping out a few games with LOVE!

User avatar
osgeld
Party member
Posts: 303
Joined: Sun Nov 23, 2008 10:13 pm

Re: Hello and Questions!

Post by osgeld » Mon Jan 05, 2009 11:04 pm

use

function update(dt)
X = X + (speed * dt)
end

instead of updating your coords in draw

and you can run love from a command line

love.exe c:\dir of prject

but unless your files are in something easy (like mine love.exe c:\lovedev\project_name\) it could be even more of a pain

LÖVER
Prole
Posts: 10
Joined: Mon Jan 05, 2009 9:09 pm

Re: Hello and Questions!

Post by LÖVER » Tue Jan 06, 2009 5:09 am

Sorry but that doesn't help much. I am using the same code to move a sprite around but I cannot for the life of me figure out how to get posX and posY approach the mouse coords correctly...

User avatar
Kaze
Party member
Posts: 189
Joined: Sat Jul 19, 2008 4:39 pm
Location: Dublin, Ireland

Re: Hello and Questions!

Post by Kaze » Tue Jan 06, 2009 9:49 am

Code: Select all

x = 300
y = 400

function draw()   
	mouseY = love.mouse.getY()
	mouseX = love.mouse.getX()
	xDis = x - mouseX
	yDis = y - mouseY
	
	-- Angle plus 180 degrees.
	ang = math.atan2(yDis, xDis) + math.pi
	
	posX = x + math.cos(ang) * 30 -- 30 is how much we should draw it outwards.
	posY = y + math.sin(ang) * 30
	
	love.graphics.point(posX, posY)
	love.graphics.point(x, y)
end
LÖVER wrote: I love LOVE so far, fairly simplistic compared to some stuff I use in school, but debugging it is a pain! I hate dragging and dropping the folder onto Love.exe is there an easier way? I would love if I could push Debug in Visual Studio and have it do that for me, is that even possible? LOVE has also inspired me to learn Lua, as well and I must say... it's so hard to script in it when using C# or C++ in school all day. I find a lot of { } and ; in my Lua :)
Here's a good trick:

Code: Select all

function keypressed( k )
	if love.keyboard.isDown( love.key_lctrl ) and k == love.key_r then
		love.system.restart( )
	end
end
Now just press ctrl+r to reload the game.

Post Reply

Who is online

Users browsing this forum: No registered users and 44 guests