Need help with my game, Dungeoneer!

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.
LaserGuns
Prole
Posts: 33
Joined: Sun Apr 29, 2012 12:55 am

Need help with my game, Dungeoneer!

Post by LaserGuns »

Me and Gage from SockMunkeeDev are working on a game called "Dungeoneer". It's a 2D sandbox game similar to terraria. We coded a terrain generator that uses tiles and generates left to right.
How could we limit the amount of columns of tiles across it generates? For example:
{ and } represent sides of the window.
@ represents one column of tiles
This is what we have now:
{@@@@@@@@@@}@@@@@@@@@@@@
The tiles continue to generate off of the screen. This causes more and more lag as you play
This is what we want:
{@@@@@@@@@@}
The columns are limited to 52 (The window width divided by 20) (20 is the width of 1 tile)
Here is the .love of our game so far. You will notice it becomes increasingly more laggy (and glitchy) as you play.

EDIT: .love file removed
Last edited by LaserGuns on Fri Jul 06, 2012 6:02 pm, edited 1 time in total.
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

Re: Need help with my game, Dungeoneer!

Post by coffee »

LaserGuns wrote:Me and Gage from SockMunkeeDev are working on a game called "Dungeoneer". It's a 2D sandbox game similar to terraria. We coded a terrain generator that uses tiles and generates left to right.
The quantity of youngsters that comes to LOVE driven with the desire of replicate something Terraria/Minecraft don't cease to amaze me! Good luck for the project. And you know that is better get another no taken name right?

You should inquire Davidbot to join as partner/helper because his "The Adventure of The Red Thing With Green Eyes", "T.A.O.T.R.T.W.G.E." for short (or "Red Green Something" for memorizable version) is basically the same concept as yours (viewtopic.php?f=5&t=9729).

veethree also was doing almost the same (viewtopic.php?f=5&t=8283) and (viewtopic.php?f=4&t=5764&p=43677).

You can also find some guidance/inspiration in Middlerun's Lovecraft (viewtopic.php?f=5&t=3526).

Lastly Don't Go Left (viewtopic.php?f=5&t=3455) aimed for something similar.
Wojak
Party member
Posts: 134
Joined: Tue Jan 24, 2012 7:15 pm

Re: Need help with my game, Dungeoneer!

Post by Wojak »

I had a quick look on the code and I noticed you are calling terrain_generate()function in love.update and love.draw (twice per frame – even once per frame is to much for that kind of function IMO), the computer I currently using have a huge problem with ruining the game even if the player is not moving...

also I would recommend to check if the image is on the screen before drawing it(images drawn of the screen use the same amount of resources as the ones on the screen)

edit:

main.lua:

Code: Select all

require "player"
require "map"
require 'menu'
require "terrain"

function love.load()
	
	love.graphics.setBackgroundColor(173,216,230)



	menu_load = true

	gamestate = "playing"
end
local i = 0
function love.update(dt)
	if gamestate == "playing" then
		player_move(dt)
		map_collide()
		player_gravity(dt)
                i = i + 1
		if i < 53 then -- limit the columns
			terrain_generate()
		end
		levelseed_randomize()
		treegenerate_randomize()
		tree_grow()
		tile:collide()
		--All functions that happen while your playing the game go here

	end
	if gamestate == "menu" then
		button:highlight()
	end




end
function love.keypressed(key,dt)--Sence player_jump uses "dt", love.keypressed needs to also
	if key == " " then
		player_jump(key,dt)--You use the key arg. and delta time.
	end
	if key == "d" then
		player.texture = love.graphics.newImage("images/playerflipped.png")
	end
	if key == "a" then
		player.texture = love.graphics.newImage("images/player.png")
	end
end
function love.keyreleased(key)
	player_resetanim(key)
end
function love.mousepressed(x,y)
	if gamestate == "menu" then
		button:click(x,y)
	end
end
function love.draw()
	if gamestate == "playing" then
		player_draw()
		--terrain_generate()
		tile:draw()

	end
	if gamestate == "menu" then
		button:draw()

	end


end
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

Re: Need help with my game, Dungeoneer!

Post by coffee »

Wojak wrote:I had a quick look on the code and I noticed you are calling terrain_generate()function in love.update and love.draw (twice per frame – even once per frame is to much for that kind of function IMO), the computer I currently using have a huge problem with ruining the game even if the player is not moving...
Well, their problems go further than that. They keep things tile and not map indexed. So you guys draw in every cycle all tiles pieces in map and don't even test to check if the x/y of tile object is on/off screen. So it's... terrible in performance and organization. Basically and technically the game is screw up in their deep roots.

Code: Select all

function love.draw()
   if gamestate == "playing" then
      player_draw()
      --terrain_generate()
      tile:draw()
   end
   if gamestate == "menu" then
      button:draw()
   end
end

Code: Select all

function tile:draw()
	for i,v in ipairs(tile) do
		love.graphics.setColor(255,255,255)
		love.graphics.draw(v.image,v.x,v.y)
	end
end
you should really start over from scratch and learn first to do tiled maps properly from wiki examples
https://love2d.org/wiki/Category:Tutorials
Zeliarden
Party member
Posts: 139
Joined: Tue Feb 28, 2012 4:40 pm

Re: Need help with my game, Dungeoneer!

Post by Zeliarden »

don't even test to check if the x/y of tile object is on/off screen.
thats nothing an if statement two cant fix, and if they are only generating terrain for the size of the screen they dont need it.
anyways why not generate in love.load()?

Code: Select all

function love.load()

for i=1, 52 do
      terrain_generate()
      levelseed_randomize()
      treegenerate_randomize()
      tree_grow()
end
...
LaserGuns
Prole
Posts: 33
Joined: Sun Apr 29, 2012 12:55 am

Re: Need help with my game, Dungeoneer!

Post by LaserGuns »

Wojak wrote:I had a quick look on the code and I noticed you are calling terrain_generate()function in love.update and love.draw (twice per frame – even once per frame is to much for that kind of function IMO), the computer I currently using have a huge problem with ruining the game even if the player is not moving...

also I would recommend to check if the image is on the screen before drawing it(images drawn of the screen use the same amount of resources as the ones on the screen)

edit:

main.lua:

Code: Select all

require "player"
require "map"
require 'menu'
require "terrain"

function love.load()
	
	love.graphics.setBackgroundColor(173,216,230)



	menu_load = true

	gamestate = "playing"
end
local i = 0
function love.update(dt)
	if gamestate == "playing" then
		player_move(dt)
		map_collide()
		player_gravity(dt)
                i = i + 1
		if i < 53 then -- limit the columns
			terrain_generate()
		end
		levelseed_randomize()
		treegenerate_randomize()
		tree_grow()
		tile:collide()
		--All functions that happen while your playing the game go here

	end
	if gamestate == "menu" then
		button:highlight()
	end




end
function love.keypressed(key,dt)--Sence player_jump uses "dt", love.keypressed needs to also
	if key == " " then
		player_jump(key,dt)--You use the key arg. and delta time.
	end
	if key == "d" then
		player.texture = love.graphics.newImage("images/playerflipped.png")
	end
	if key == "a" then
		player.texture = love.graphics.newImage("images/player.png")
	end
end
function love.keyreleased(key)
	player_resetanim(key)
end
function love.mousepressed(x,y)
	if gamestate == "menu" then
		button:click(x,y)
	end
end
function love.draw()
	if gamestate == "playing" then
		player_draw()
		--terrain_generate()
		tile:draw()

	end
	if gamestate == "menu" then
		button:draw()

	end


end
Thank you! This is exactly what we needed.
LaserGuns
Prole
Posts: 33
Joined: Sun Apr 29, 2012 12:55 am

Re: Need help with my game, Dungeoneer!

Post by LaserGuns »

coffee wrote:And you know that is better get another no taken name right?
What? I chose the name because I was planning on adding dungeons that generate underground. Is there a game called Dungeoneer already?
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

Re: Need help with my game, Dungeoneer!

Post by coffee »

LaserGuns wrote:What? I chose the name because I was planning on adding dungeons that generate underground. Is there a game called Dungeoneer already?
Rule number #1 when choosing games names. Don't choose a taken one, specially if copyrighted. Nothing that Google don't reveal in (micro) seconds. Yes, there is a collectible card-game with that name. Also a rogue game called Dungeoneers in the making wich I already knew about it. They won't care if you choose it because x or y. Both variations are taken period. Avoid possible name trademark conflicts. They probably won't like another game with same exact name. And help yourself choosing an unique "googable" name for your project. You can still use it anyway but well it's your problem and risk. If you choose a new one just google it first :)
LaserGuns
Prole
Posts: 33
Joined: Sun Apr 29, 2012 12:55 am

Re: Need help with my game, Dungeoneer!

Post by LaserGuns »

coffee wrote:
LaserGuns wrote:What? I chose the name because I was planning on adding dungeons that generate underground. Is there a game called Dungeoneer already?
Rule number #1 when choosing games names. Don't choose a taken one, specially if copyrighted. Nothing that Google don't reveal in (micro) seconds. Yes, there is a collectible card-game with that name. Also a rogue game called Dungeoneers in the making wich I already knew about it. They won't care if you choose it because x or y. Both variations are taken period. Avoid possible name trademark conflicts. They probably won't like another game with same exact name. And help yourself choosing an unique "googable" name for your project. You can still use it anyway but well it's your problem and risk. If you choose a new one just google it first :)
Okay, do you have any ideas of what I should name it? I can't think of anything else. Maybe something like Stonerealm. Yeah, I actually think I'm gonna use that
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

Re: Need help with my game, Dungeoneer!

Post by coffee »

LaserGuns wrote:Okay, do you have any ideas of what I should name it? I can't think of anything else. Maybe something like Stonerealm. Yeah, I actually think I'm gonna use that
It's always good that the name is a personal choice but you don't have to name it for now. If you don't have certain of it or don't feel it's the right one don't rush it. Some experience tell me that better names always come when project goals or features are been developed. So sometimes "ridiculous"project codenames (that never are used in final name) are sometimes the best choices for early stages :)

Why not keep it for now "Project :StoneRealm" then and mature a bit the game so something peculiar in the game gave inspiration to rebrand it. StoneRealm isn't so good as Dungeoneer but later a better name will always appear.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 3 guests