More monsters

This commit is contained in:
Linus Probert 2017-12-14 09:48:49 +01:00
parent 0fcf0afc39
commit 80ab804e07
4 changed files with 108 additions and 11 deletions

View File

@ -1,9 +1,10 @@
x Add walls and stuff to maps
x Implement simple box collisions
o Add enemies (generated through lua)
x Add enemies (generated through lua)
x Monster object created
x Lua bindings for creation
o Making some better generation and randomeness
x Making some better generation and randomeness
- Move "texture clip" from texture to sprite
- Hitting enemies
- Moving enemies
- Lower levels

View File

@ -123,8 +123,6 @@ local map_matrix = generate_path()
-- Print path [Debug]
-- print_matrix(map_matrix)
monster_gen.add_monster_to_room(map);
for i=1,10 do
for j=1,10 do
local room = map_matrix[i][j]
@ -132,6 +130,7 @@ for i=1,10 do
set_current_room(map, i-1, j-1);
if room.type == "room" then
room_builder.build_square_room(map, room)
monster_gen.add_monster_to_room(map, i-1, j-1);
elseif room.type == "coridoor" then
room_builder.build_coridoor_room(map, room)
end

View File

@ -170,8 +170,14 @@ local function add_walls_to_room (map)
if random(2) == 1 then
add_decoration(map, 4, 3, repack(lightDecor.candle2))
end
if random(2) == 1 then
add_decoration(map, 11, 3, repack(lightDecor.candle2))
end
if random(2) == 1 then
add_decoration(map, 4, 9, repack(lightDecor.candle2))
end
if random(2) == 1 then
add_decoration(map, 11, 9, repack(lightDecor.candle2))
end
end

View File

@ -1,15 +1,106 @@
local module = {}
local random = math.random
local black_ant = {
texturePath1 = "assets/Characters/Pest0.png",
texturePath2 = "assets/Characters/Pest1.png",
clipX = 16,
clipY = 64,
local texturePaths = {
aquatic0 = "assets/Characters/Aquatic0.png",
aquatic1 = "assets/Characters/Aquatic1.png",
avian0 = "assets/Characters/Avian0.png",
avian1 = "assets/Characters/Avian1.png",
cat0 = "assets/Characters/Cat0.png",
cat1 = "assets/Characters/Cat1.png",
demon0 = "assets/Characters/Demon0.png",
demon1 = "assets/Characters/Demon1.png",
dog0 = "assets/Characters/Dog0.png",
dog1 = "assets/Characters/Dog1.png",
elemental0 = "assets/Characters/Elemental0.png",
elemental1 = "assets/Characters/Elemental1.png",
humanoid0 = "assets/Characters/Humanoid0.png",
humanoid1 = "assets/Characters/Humanoid1.png",
misc0 = "assets/Characters/Misc0.png",
misc1 = "assets/Characters/Misc1.png",
pest0 = "assets/Characters/Pest0.png",
pest1 = "assets/Characters/Pest1.png",
pant0 = "assets/Characters/Plant0.png",
plant1 = "assets/Characters/Plant1.png",
player0 = "assets/Characters/Player0.png",
player1 = "assets/Characters/Player1.png",
quadroped0 = "assets/Characters/Quadraped0.png",
quadroped1 = "assets/Characters/Quadraped1.png",
reptile0 = "assets/Characters/Reptile0.png",
reptile1 = "assets/Characters/Reptile1.png",
rodent0 = "assets/Characters/Rodent0.png",
rodent1 = "assets/Characters/Rodent1.png",
slime0 = "assets/Characters/Slime0.png",
slime1 = "assets/Characters/Slime1.png",
undead0 = "assets/Characters/Undead0.png",
undead1 = "assets/Characters/Undead1.png",
}
local enemies = {
{ texturePaths.pest0, texturePaths.pest1, 0, 0 },
{ texturePaths.pest0, texturePaths.pest1, 16, 0 },
{ texturePaths.pest0, texturePaths.pest1, 32, 0 },
{ texturePaths.pest0, texturePaths.pest1, 48, 0 },
{ texturePaths.pest0, texturePaths.pest1, 64, 0 },
{ texturePaths.pest0, texturePaths.pest1, 96, 0 },
{ texturePaths.pest0, texturePaths.pest1, 112, 0 },
function module.add_monster_to_room(map)
add_monster(map, 128, 128, black_ant);
{ texturePaths.pest0, texturePaths.pest1, 0, 16 },
{ texturePaths.pest0, texturePaths.pest1, 16, 16 },
{ texturePaths.pest0, texturePaths.pest1, 32, 16 },
{ texturePaths.pest0, texturePaths.pest1, 48, 16 },
{ texturePaths.pest0, texturePaths.pest1, 64, 16 },
{ texturePaths.pest0, texturePaths.pest1, 80, 16 },
{ texturePaths.pest0, texturePaths.pest1, 0, 32 },
{ texturePaths.pest0, texturePaths.pest1, 16, 32 },
{ texturePaths.pest0, texturePaths.pest1, 32, 32 },
{ texturePaths.pest0, texturePaths.pest1, 48, 32 },
{ texturePaths.pest0, texturePaths.pest1, 64, 32 },
{ texturePaths.pest0, texturePaths.pest1, 80, 32 },
{ texturePaths.pest0, texturePaths.pest1, 0, 48 },
{ texturePaths.pest0, texturePaths.pest1, 16, 48 },
--{ texturePaths.pest0, texturePaths.pest1, 32, 48 },
{ texturePaths.pest0, texturePaths.pest1, 48, 48 },
{ texturePaths.pest0, texturePaths.pest1, 64, 48 },
{ texturePaths.pest0, texturePaths.pest1, 0, 64 },
{ texturePaths.pest0, texturePaths.pest1, 16, 64 },
{ texturePaths.pest0, texturePaths.pest1, 32, 64 },
{ texturePaths.pest0, texturePaths.pest1, 48, 64 },
{ texturePaths.pest0, texturePaths.pest1, 0, 80 },
{ texturePaths.pest0, texturePaths.pest1, 16, 80 },
{ texturePaths.pest0, texturePaths.pest1, 32, 80 },
{ texturePaths.pest0, texturePaths.pest1, 48, 80 },
{ texturePaths.pest0, texturePaths.pest1, 0, 96 },
{ texturePaths.pest0, texturePaths.pest1, 16, 96 },
{ texturePaths.pest0, texturePaths.pest1, 32, 96 },
{ texturePaths.pest0, texturePaths.pest1, 0, 112 },
{ texturePaths.pest0, texturePaths.pest1, 16, 112 },
{ texturePaths.pest0, texturePaths.pest1, 32, 112 },
{ texturePaths.pest0, texturePaths.pest1, 48, 112 },
}
local function repack(data)
return {
texturePath1 = data[1],
texturePath2 = data[2],
clipX = data[3],
clipY = data[4],
}
end
function module.add_monster_to_room(map, roomx, roomy)
local count = random(3)
for i=0,count do
local x = (roomx * 512) + (random(13) + 1) * 32
local y = (roomy * 384) + (random(9) + 1) * 32
add_monster(map, x, y, repack(enemies[random(#enemies)]));
end
end
return module