Pack of noob 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
Spessman
Prole
Posts: 9
Joined: Sun Oct 11, 2015 2:19 pm

Pack of noob questions

Post by Spessman »

Good os.date() to all.
I have some noob or stupid questions about love2d and lua.
I do on love2d a big(rpg) game, i know this bad choice for "my first game", but me need some great experience.

So...
1. My game is big and i want to create controller for all mobs. Each mob have function life() and it must pass trough loop. This slow down the game and there need something like another thread. How i can run this loop in parallel to main thread? love.thread - bad choice, because i want run only function without creating file and channels for this. And i'm doubt about coroutines. Please suggest the best way.

2. Game have the big map with 1000x1000 32x32 tiles and about 10 z-levels. Some tiles can be transparent and i want to draw objects in 1 z-lvl down, but i don't know how. I use the spritebatch for this(thanks to all guys from my latest topic) and pass trough loop all objects in screen area, but before i pass all objects on z-lvl for create list with objects in screen area. So, I need to draw current z-lvl and lower z-lvl in specific places. And do it fast. How?
Objects not tied to tiles!

3. I have many polygonal objects in screen area. And i want to get object by pointer. Earlier i'm just check contents of tile and pixels in their icon. Now i can't and haven't ideas or algorithms for it. Any suggestions?

4. I'm walked away from bounding box collision. I want the vertex-based collision and i'm looking for good algorithms. Where i can find polygonal collision check(with expulsion, desirable)?


Sorry for my english. It looks bad...
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Pack of noob questions

Post by zorg »

Hi,
Spessman wrote:4. I'm walked away from bounding box collision. I want the vertex-based collision and i'm looking for good algorithms. Where i can find polygonal collision check(with expulsion, desirable)?
You can use HardonCollider for polygonal collision detection.
Spessman wrote:3. I have many polygonal objects in screen area. And i want to get object by pointer. Earlier i'm just check contents of tile and pixels in their icon. Now i can't and haven't ideas or algorithms for it. Any suggestions?
By pointer, i'm guessing you mean the mouse cursor's position. Whether you use a camera system or not, HC can be used for this as well, if you imagine the cursor being a very tiny circle colliding with the other shapes.
Spessman wrote:2. Game have the big map with 1000x1000 32x32 tiles and about 10 z-levels. Some tiles can be transparent and i want to draw objects in 1 z-lvl down, but i don't know how. I use the spritebatch for this(thanks to all guys from my latest topic) and pass trough loop all objects in screen area, but before i pass all objects on z-lvl for create list with objects in screen area. So, I need to draw current z-lvl and lower z-lvl in specific places. And do it fast. How?
Objects not tied to tiles!
Use one (or more, if you have more than one atlas image you want to use for sprites) spritebatches per-z-level, that way you can have your tiles and objects drawn in the correct z-order. As for optimizing speed, only draw out what is visible on the screen, either by using love.graphics.setScissor, or adding only the visible sprites to the spritebatches (and removing the ones that went out of view); i'm honestly not sure whether the last one would make it faster or not though.
Also, can't you partition up the map into smaller zones or something?
Spessman wrote:1. My game is big and i want to create controller for all mobs. Each mob have function life() and it must pass trough loop. This slow down the game and there need something like another thread. How i can run this loop in parallel to main thread? love.thread - bad choice, because i want run only function without creating file and channels for this. And i'm doubt about coroutines. Please suggest the best way.
You only have those three options, using a thread, or a coroutine (though that won't really help you if the problem is that all the mob updates can't finish under one update cycle, or leaving it in the main thread.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Spessman
Prole
Posts: 9
Joined: Sun Oct 11, 2015 2:19 pm

Re: Pack of noob questions

Post by Spessman »

You can use HardonCollider for polygonal collision detection.
Thanks. Very useful.
If you know another one library or algorithm , i want to take a look on it.
if you imagine the cursor being a very tiny circle colliding with the other shapes.
Very smart. Thanks.
Maybe you have another variant? Just in case.
Use one (or more, if you have more than one atlas image you want to use for sprites) spritebatches per-z-level, that way you can have your tiles and objects drawn in the correct z-order. As for optimizing speed, only draw out what is visible on the screen, either by using love.graphics.setScissor, or adding only the visible sprites to the spritebatches (and removing the ones that went out of view); i'm honestly not sure whether the last one would make it faster or not though.
Also, can't you partition up the map into smaller zones or something?
But Scissor only cuts area? Maybe i use this incorrectly. I'm pass objects and tiles on z-lvl trough loop, draw and set scissors. This is really slow.
I don't know visible objects, but want to recognize them. Check transparent tiles coordinates and compare all objects on lower z-lvl? That's slow...
You only have those three options, using a thread, or a coroutine (though that won't really help you if the problem is that all the mob updates can't finish under one update cycle, or leaving it in the main thread.
So poor selection... I can't leave it in main thread. And can't use love's thread. Coroutines - my only way. And now i want to know how stable they works with love2d.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Majestic-12 [Bot] and 7 guests