Re-Introduction

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
zohnny
Prole
Posts: 7
Joined: Mon Jul 25, 2011 9:53 pm

Re-Introduction

Post by zohnny »

For some reason I have become interested in löve again, the last time I messed with it was last summer. It's sort of cool seeing all the old users from then... Everybody was really nice and patient with me, and I hope everyone will still be patient because I have forgot everything. I took a Flash class last semester, and I hope some of that will help me.

Anyways... I'm trying to recreate a toy I made in flash, where a ball would bounce around with simple physics, you could hit different buttons and it would toggle wind, the size of the ball, etc.

There was a way I could simulate acceleration, by making the x of the ball equal a variable, and the y a variable also. Then to simulate gravity I would do something like "dx = dx + 1" (where dx was the variable of x). The ball would speed up, instead of having the speed remain constant. If anyone knows how I can define variables like that, I would appreciate the help. :awesome:

Anyways, I hope to actually stick with the program this time, so I could make some (semi) amusing games.

EDIT: I just remembered the "obey" thing again, I'll get to working on an avi now :D
User avatar
Taehl
Dreaming in associative arrays
Posts: 1025
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

Re: Re-Introduction

Post by Taehl »

The main question here is whether you want to use Box2D (Love's built-in, high-powered but not entirely easy to use physics engine), or make your own physics system. If the former, you'll need advice from someone other than me. The latter, though, I may be able help out with.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: Re-Introduction

Post by tentus »

I used the builtin Box2D physics for my first big Love game, and aside from a few serious issues that have been resolved (https://bitbucket.org/rude/love/issue/1 ... -not-crash), it worked out pretty OK. The big thing is to plan out how things will interact before you start hammering out some half-baked system.
Kurosuke needs beta testers
User avatar
slime
Solid Snayke
Posts: 3131
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Re-Introduction

Post by slime »

Yeah, I've had very little issues with box2d once I got past its quirks. 0.8.0 will have some major changes to the way it works though, so don't get too comfortable. :P
User avatar
tentus
Inner party member
Posts: 1060
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

Re: Re-Introduction

Post by tentus »

Really? What's in the works, I haven't noticed anything big getting changed, just a bunch of fixes.
Kurosuke needs beta testers
User avatar
slime
Solid Snayke
Posts: 3131
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Re-Introduction

Post by slime »

It's being updated to box2d 2.1, so these changes implemented as a lövely Lua API.
User avatar
zohnny
Prole
Posts: 7
Joined: Mon Jul 25, 2011 9:53 pm

Re: Re-Introduction

Post by zohnny »

Taehl wrote:The main question here is whether you want to use Box2D (Love's built-in, high-powered but not entirely easy to use physics engine), or make your own physics system. If the former, you'll need advice from someone other than me. The latter, though, I may be able help out with.
Ok, thanks. What do you suggest I should try in writing my own physics? I'm thinking now of just making a block breaker type game, but I would still need to know how to bounce the ball off of the bricks and the paddle. Using my previous idea, I remember I could do something like "if (ball hits paddle) then dy = dy * -1". Not sure how that would work in löve.
User avatar
Kadoba
Party member
Posts: 399
Joined: Mon Jan 10, 2011 8:25 am
Location: Oklahoma

Re: Re-Introduction

Post by Kadoba »

I'm guessing by physics you mean simple collision detection. For that HardonCollider is easy to set up and use.
User avatar
zohnny
Prole
Posts: 7
Joined: Mon Jul 25, 2011 9:53 pm

Re: Re-Introduction

Post by zohnny »

That seems like it will help, thanks.

But I have no idea how to install it or how to use it. Is it just some files that I add to my game to add a module? Sorry I'm pretty much brand new at this, I try to learn as much as I can through the wiki but I have no experience.

Right now I'm still working on a block breaker-type game, I'm almost done with all the artwork (still making everything as an exponent of 2, I don't know if that still screws up on older computers), and I'm starting to do some of the code, such as loading all the images and making a menu button to start it.

My main question is if there is some way to use direction, I think I can write my own physics if I just know how direction works.

Second question, (and I know this is probably pretty obvious,) is how do I use multiple .lua files in my game? I'm thinking the main.lua file should load all of the images, then there should be like a gameplay.lua file that works all the ball movements, the paddle control, and the level generator. How do I call the files to run? Are there specific names I have to give to the files?

Third question, this one is sort of complex. For a level generator, I want to use a grid system, and the bricks are randomly placed behind a distance from the paddle. Each level will contain more bricks, until the area is completely full and the game will display a game over screen. Would it be easier to have set levels, and just write each level specifically, or to have a random level generator and let it create levels?

I know this is a lot that I'm asking... I just really hope to learn all the basics in a game or two before I start being serious with games. Thanks to anyone who helps, it really means a lot to learn how to program games.

EDIT: I'm thinking the main.lua file should just load the images and draw them, as well as work the menu. Is that the best way to do it?

EDIT 2: For some reason I can't find how to fix the window to a certain size, I think right now it's at the default 800 x 600 and I need it to be at 512 x 512.

I hope somebody will be able to help me with some, if not all of my questions but I am really just trying to learn so I can contribute at least a little bit. :nyu:
User avatar
Kadoba
Party member
Posts: 399
Joined: Mon Jan 10, 2011 8:25 am
Location: Oklahoma

Re: Re-Introduction

Post by Kadoba »

But I have no idea how to install it or how to use it. Is it just some files that I add to my game to add a module? Sorry I'm pretty much brand new at this, I try to learn as much as I can through the wiki but I have no experience.
Just add the folder to your .love and load it using require "HardonCollider"
My main question is if there is some way to use direction, I think I can write my own physics if I just know how direction works.
If you don't use love.physics you have to do all of the math yourself. Here are the movement functions for game objects that I use:

Code: Select all

-- Moves the object to the relative location
function BaseObject:move(x,y)
	self.x, self.y = self.x + x or 0, self.y + y or 0
end

-- Moves the object to the absolute location
function BaseObject:moveTo(x, y)
	self.x, self.y = x or self.x, y or self.y
end

-- Moves the object towards the given location
function BaseObject:moveToward(x, y, speed)
	if self.x == x and self.y == y then return false end
	local dirx, diry = x - self.x, y - self.y
	local hyp = math.sqrt(dirx*dirx + diry*diry)
	if hyp > speed*2 then
		self:move(dirx/hyp*speed, diry/hyp*speed)
	else
		self:moveTo(x,y)
	end
	return true
end

-- Moves the object towards the direction (in degrees)
function BaseObject:moveDir(dir, speed)
	local x = math.cos(math.rad(dir))
	local y = -math.sin(math.rad(dir))
	self:move(x*speed, y*speed)
end
Second question, (and I know this is probably pretty obvious,) is how do I use multiple .lua files in my game? I'm thinking the main.lua file should load all of the images, then there should be like a gameplay.lua file that works all the ball movements, the paddle control, and the level generator. How do I call the files to run? Are there specific names I have to give to the files?
Use the require to run other files once. If you have a file called LoadImages.lua then call it in another file with

Code: Select all

require "LoadImages"
Third question, this one is sort of complex. For a level generator, I want to use a grid system, and the bricks are randomly placed behind a distance from the paddle. Each level will contain more bricks, until the area is completely full and the game will display a game over screen. Would it be easier to have set levels, and just write each level specifically, or to have a random level generator and let it create levels?
This really depends on the game. If you're just placing random blocks then that shouldn't be too hard.
I know this is a lot that I'm asking... I just really hope to learn all the basics in a game or two before I start being serious with games. Thanks to anyone who helps, it really means a lot to learn how to program games.
Don't feel bad for asking questions. Although first starting out I recommend to first read the first 7 chapters of Programming in Lua. After that, do some of the tutorials.
EDIT: I'm thinking the main.lua file should just load the images and draw them, as well as work the menu. Is that the best way to do it?
It really depends on the size of your game. It's best to separate responsibilities into different files.
EDIT 2: For some reason I can't find how to fix the window to a certain size, I think right now it's at the default 800 x 600 and I need it to be at 512 x 512.:
Use a config file.
Post Reply

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot] and 60 guests