Hello,
I desperately need advice on how I should prepare and set-up my code and things for the future when I start creating the images for the ground and platforms and make a variety of terrain patterns and levels. For instance, if there's some way to make a floor entity, that can have it's width or height scaled up or down, and repeat certain "tiles" as needed. I'm also wondering if it can assign "crust" tiles to the outer edges while repeating the inside tiles, or if I should make separate entities for the floor that I want to be scalable and for the crust.
Right now I have nothing but a global "yFloor" variable that shows the height of one floor because I've been perpetually confused by relating boxes to each other
Also... differentiating between different classes of objects (player, projectile, enemy, floor, etc) and coding different results for each of their collisions.
I think I have the start of something like this, as you can see the game prints the player object's name and it's class ("player").
Here's my code
Advice to prepare for level design
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- aliceandsven
- Prole
- Posts: 13
- Joined: Thu Mar 29, 2012 3:15 pm
Advice to prepare for level design
- Attachments
-
- code.love
- (3.05 KiB) Downloaded 103 times
Projects: 1) shape story xiv: fabula nova questalis [mouse-avoid game]
Re: Advice to prepare for level design
I find your question confusing, but what I think you're trying to do is simply organize all the objects in your game. If that's the case then I use a really simple table system for objects.
I write this assuming you don't want to do a tilemap, if you do this can help: https://love2d.org/wiki/Tutorial:Tile-based_Scrolling
The tilemap only organizes the level, though.
For objects that can be anywhere I just use this table system:
. . . and variations on this.
You can loop through them all in the same way you draw them when you solve for collisions if you put the collision object in the objectdat[id] subtable.
And I apologize if this wasn't what you were asking for, though it seems like it is . . . hope it helps.
I write this assuming you don't want to do a tilemap, if you do this can help: https://love2d.org/wiki/Tutorial:Tile-based_Scrolling
The tilemap only organizes the level, though.
For objects that can be anywhere I just use this table system:
Code: Select all
objects = {}
objectdat = {}
function objects:new (id, type, x, y)
objectdat[id] = {}
objectdat[id].type = type --I use this to correspond to a texture id for drawing (texture table created in a similar way)
objectdat[id].x = x
objectdat[id].y = y
end
function objects:drawall() -- assuming you have ordered your object ids from 1 - n, let n = objecttotal
for i = 1, objecttotal do
love.graphics.draw(textures[objectdat[i].type], objectdat[i].x, objectdat[i].y)
end
end
You can loop through them all in the same way you draw them when you solve for collisions if you put the collision object in the objectdat[id] subtable.
And I apologize if this wasn't what you were asking for, though it seems like it is . . . hope it helps.
It was the best of times, it was the worst of times . . .
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 12 guests