Page 35 of 37

Re: My Adventure Game Engine - GIT friendly since 2010!

Posted: Thu Jun 09, 2011 8:11 pm
by Jasoco
I just implemented multiple main character support.
ALDL6.png
ALDL6.png (30.86 KiB) Viewed 510 times
Each one can have its own appearance sheet. In this case we have Haley and Kaylee. Bestest friends forever. Or something. I can switch between them by pressing P and the camera switches to the current one. This will be useful for games where you want a story that takes place from the viewpoint of multiple characters and you want to switch between them at will.

I'll have to figure out the loading and changing of maps in the chance the other players are somewhere else in the world now.

Eventually my updates will be in a new official thread for the new engine. This thread will end. (I might have someone lock it or something once I get the new thread up) Once I get something good in place.

Re: My Adventure Game Engine - GIT friendly since 2010!

Posted: Thu Jun 09, 2011 8:39 pm
by slime
This is looking great! Two things though: normalize your movement vectors, and consider using spritebatches to draw the game word where possible. :)

Re: My Adventure Game Engine - GIT friendly since 2010!

Posted: Thu Jun 09, 2011 8:53 pm
by Jasoco
slime wrote:This is looking great! Two things though: normalize your movement vectors, and consider using spritebatches to draw the game word where possible. :)
What? Is that like reticulating splines? And I don't know spritebatches yet. I use Quads.

Re: My Adventure Game Engine - GIT friendly since 2010!

Posted: Thu Jun 09, 2011 9:00 pm
by slime
See here or here (scroll down until the "normalization" sections). Without normalizing them you move 1.41x faster diagonally.

Re: My Adventure Game Engine - GIT friendly since 2010!

Posted: Thu Jun 09, 2011 9:03 pm
by TechnoCat
I'm pretty sure he is just telling you to make your diagonal movements the same speed as your up/down/left/right movements.

Re: My Adventure Game Engine - GIT friendly since 2010!

Posted: Thu Jun 09, 2011 9:07 pm
by Jasoco
Ah. Yes, that makes sense. It is part of the plan. I've always added the same speed to the horizontal as I add to the vertical when moving both right and down at the same time. Many people don't think to fix that.

Re: My Adventure Game Engine - GIT friendly since 2010!

Posted: Fri Jun 10, 2011 10:40 pm
by Jasoco
Until I figure out what the correct multiplier should be or I rewrite the movement functions, I'm using player speed * 0.8 when moving diagonal. I assume this isn't exactly correct. What would the correct value be for moving 45º?

Re: My Adventure Game Engine - GIT friendly since 2010!

Posted: Fri Jun 10, 2011 10:59 pm
by bartbes
That sounds like it's approaching sqrt(2), which is approximately 0.74.

Re: My Adventure Game Engine - GIT friendly since 2010!

Posted: Sat Jun 11, 2011 4:10 am
by Kadoba
I use these movement functions for my game objects. Feel free to use them if you want.

Code: Select all

local math = math

-- 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 counterclockwise from the positive x axis)
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

Re: My Adventure Game Engine - GIT friendly since 2010!

Posted: Sat Jun 11, 2011 5:20 am
by Jasoco
bartbes wrote:That sounds like it's approaching sqrt(2), which is approximately 0.74.
Thanks. I'll use that for now. The players certainly move diagonally more realistically now.
Kadoba wrote:I use these movement functions for my game objects. Feel free to use them if you want.
Looks exactly like what I was looking for. I'll see if I can implement that method tomorrow. Thanks!


I've added the beginnings of a 2-player mode where you can control both characters at once. I might add up to 4 at some point, but for now 2 will be enough to play with. Since I want this engine to be versatile, I want to be able to have the option to do anything. Want it to be a Zelda or RPG? There it is. Want it to be an arcade style 2-player collect-a-thon game or something like Bomberman? There it is.

Right now as the players move around, if the map is scrollable, the camera will be centered between them. Like how it does it in those multiplayer games like Smash Brothers, NEW Super Mario Bros. and those online Super Mario X games. It doesn't zoom though for obvious reasons. But I might look into a way of splitting the screen if the players get too far apart, but I will probably just end up preventing the players from leaving the bounds of the screen when they move too far apart, so you have to work together.

I also have a bunch of enemies wandering around. There's no overlap detection yet, but it's on the way.
OgZxJ.png
OgZxJ.png (33.85 KiB) Viewed 509 times