Hey LOVE!
I'm making this game called XAN its an arcade game about destroying rocks. I've run into a few programming issues and I want to your opinion on the best route to take going forward.
Currently the player can Walk, Crouch, Jump and Grab(play a grab animation). You can jump by pressing LMB and grab by Pressing RMB. I'm trying to keep the control scheme simple so I can port the logic to a touch device.
Moving forward requires some functionality that I'm not sure how to approach so i'm going to give you the abstract of how I want it to work. If you lovely folks could give me some suggestions toward those goals that would be awesome.
(1 )Collision and Objects
Right now I'm using a 'world' table and I'm inserting tables from external files like "player" and "rock". Early on I found that this is sort of a singleton pattern. I need a way to check collision between the player and however many rocks are spawned in the level.
(2 ) Grabbing and slamming rocks.
The player (XAN) should not be able to walk through rocks. If Xan is grabbing while he is blocked by a rock then the animation mode should change to 'once' or seek to the last frame of the grab animation where xan appears to be holding the rock. If you 'Jump' while you are holding the rock then Xan should play the slam animation or... execute the Slam Procedure where the rock is attached to Xan until xan returns to the ground and destroys the rock.
-- When a rock is destroyed all I want to do is create a new rock. ( and score points and modify other game variables but for now I just want to create a new rock )
(3) Animation effects
How can I implement a class of behaviors that are code driven animations. Things that I can use to give more visual feedback the same way that we use sound effects. A good example is if I want to shake the player and play a noise to signify that Xan cannot lift the rock . Or if I want the rock to flash when the Xan grabs it. Or shaking the BG assets so the slam appears to have impact. How can I start building these mechanisms?
I really do want to build these things myself. Any tips on the implementation of the behaviors listed above would be much appreciated.
XAN in Love WIP -- Help Moving forward.
XAN in Love WIP -- Help Moving forward.
I like nonsense, it wakes up the brain cells. Fantasy is a necessary ingredient in living, It's a way of looking at life through the wrong end of a telescope. Which is what I do, And that enables you to laugh at life's realities.
- Dr. Seuss
- Dr. Seuss
Re: XAN in Love WIP -- Help Moving forward.
Hi
I will try to help but I am new to love myself. But I am a rock destroy expert
Or you could for-loop through all the rocks and calculate their distance to the player. If the distance is small enough, there is a collision.
I used this technic here: http://love2d.org/forums/viewtopic.php?f=5&t=1716
It might be worth looking at because there is rock destroying, rock creating, rocks killing the player, rocks splitting into smaller rocks and so much more
Each rock has a flash_time variable. If it is > 0, draw the rock flashing.
For example look at the shield in my game.
Does this help?
I will try to help but I am new to love myself. But I am a rock destroy expert
Did you look at the collision callin function? It is explained in the wiki. Whenever 2 objects (not sure if it was shapes or bodies) in a world collide this function is called. You can set the "data" property of shapes to know if it is a rock, player or something else.I need a way to check collision between the player and however many rocks are spawned in the level.
Or you could for-loop through all the rocks and calculate their distance to the player. If the distance is small enough, there is a collision.
I used this technic here: http://love2d.org/forums/viewtopic.php?f=5&t=1716
It might be worth looking at because there is rock destroying, rock creating, rocks killing the player, rocks splitting into smaller rocks and so much more
If you add shapes do your bodies/gameobjects and set the parameters correct then the physic engine of Löve will take care of that.The player (XAN) should not be able to walk through rocks.
Maybe like this:A good example is if I want to shake the player and play a noise to signify that Xan cannot lift the rock . Or if I want the rock to flash when the Xan grabs it. Or shaking the BG assets so the slam appears to have impact. How can I start building these mechanisms?
Each rock has a flash_time variable. If it is > 0, draw the rock flashing.
Code: Select all
When a rock should start flashing:
if rock[i] gets hit then rock[i].flash_time = 60
...
...
When drawing the rocks you do:
if rock[i].flash_time > 0 then
draw flashing rock
rock[i].flashtime - 1
else
draw normal rock
If Xan is grabbing while he is blocked by a rock then the animation mode should change to 'once' or seek to the last frame of the grab animation where xan appears to be holding the rock.
Code: Select all
for i=0 to number of rocks
if player.direction = faces_left then --so the player can only grab rocks he is looking at
if rock[i].x < player.pos_x then
if distance (rock[i], player) then grab (rock[i])
if player.direction = faces_right then
if rock[i].x > player.pos_x then
if distance (rock[i], player) then grab (rock[i])
...
...
function grab
grabed_rock.is_grabed = true
end
...
...
function update ()
for i=0 to number of rocks
if rock[i].is_grabed == true then rock[i].x = player.pos_x rock[i].y = player[i].pos_y - playerheight --hold the grabed rock centered above the players head
end
Re: XAN in Love WIP -- Help Moving forward.
Thank you so much!
This is very helpful! I'll try implementing these over the next couple of days and I'll post a new version soon.
This is very helpful! I'll try implementing these over the next couple of days and I'll post a new version soon.
I like nonsense, it wakes up the brain cells. Fantasy is a necessary ingredient in living, It's a way of looking at life through the wrong end of a telescope. Which is what I do, And that enables you to laugh at life's realities.
- Dr. Seuss
- Dr. Seuss
Re: XAN in Love WIP -- Help Moving forward.
Hey I made some progress with XAN!!!
Right now I'm working out the rock class to make sure it has all the things I need.
I'm using class.lua it's an extension of a LUA tutorial an early lover gave me a while ago.
I'm working many sides of this development to see how full of a feeling I can share with love.
Right now I'm working out the rock class to make sure it has all the things I need.
I'm using class.lua it's an extension of a LUA tutorial an early lover gave me a while ago.
I'm working many sides of this development to see how full of a feeling I can share with love.
- Attachments
-
- xanBuild819.love
- Still working, added some sound. Also some basic gameplay.
- (3.3 MiB) Downloaded 344 times
I like nonsense, it wakes up the brain cells. Fantasy is a necessary ingredient in living, It's a way of looking at life through the wrong end of a telescope. Which is what I do, And that enables you to laugh at life's realities.
- Dr. Seuss
- Dr. Seuss
Re: XAN in Love WIP -- Help Moving forward.
no matter how hard i slam the rock it would not fight back
Re: XAN in Love WIP -- Help Moving forward.
Moving on with the game. I'm having an issue with my rock class. I want to be able to spawn rocks with the press of a button. Do I want to add to a rocks table?
Please take a gander and let me know if you see anything I can fix.
Please take a gander and let me know if you see anything I can fix.
Code: Select all
require("class.lua")
local boulder = lg.newImage("rock.png")
--Button = class(function(obj, text, x, y)<paramAssignment> end) -- remember we can make a class this way.
-- obj is the first arg in the function in class. This gives us "class behaviors" like defining methods using
-- self for instances of the rock in the future.
---[[
newRock = class(function(obj, x, y, weight) -- this is the definition of the function that will create the rocks.
-- positioning
obj.x = x
obj.y = y
obj.weight = weight
obj.state = "rest" -- this is for fun physics.
-- game logic
obj.value = 50 * weight -- bigger rocks. There is more to the point multiplier system.
obj.sSpeed = weight * 10
-- change art based on weight.
if obj.weight == 1 then
obj.img = boulder
end
-- in short it's value will be multiplied by stamina in the add points function.
-- There will need to be a class for dynamic text. That needs to flash and move.
-- keep up the style.
--drawVars -- container we pass to the draw function. WE also use them for collision.
---[[
obj.drawVars = {
x = obj.x,
y = obj.y,
xo = obj.img:getWidth()/2, -- offset is rather important to this system.
yo = obj.img:getHeight(),
sx = 1,
sy = 1,
rot = 0, -- we can make these more dynamic later.
}
--]]
end)
--]]
-- we need to keep the xan references the same. And make sure we change the rock. references to self.property.
---[[
function newRock:update(dt)
local frict = 1
--self.sSpeed = (25/self.weight) -- simple DIY algorithm. Lets slow down there
if xan.state == "kick" and checkHit(xan,self) then
self.state = "slide"
end
if self.state == "slide" then
self.Slide() -- this function is right. But isn't called in the right way.
end
if self.state == "rest" then
self.x = self.x
self.y = self.y
end
--keep the self on stage.
local edgeRight = self.x + self.drawVars.xo
local edgeLeft = self.x - self.drawVars.xo
if edgeRight + self.sSpeed > lg.getWidth() then -- hits edge of the screen.
self.x = lg.getWidth() - self.drawVars.xo
self.state = "rest"
elseif edgeLeft - self.sSpeed < 0 then -- hits edge of the screen.
self.x = self.drawVars.xo
self.state = "rest"
end
-- update self gravity.
if self.y < groundLevel and checkHit(xan,self)== false then
self.y = self.y + grav
end
end
function newRock:draw()
lg.draw(self.img, self.x, self.y, self.drawVars.rot,self.drawVars.sx, self.drawVars.sy, self.drawVars.xo, self.drawVars.yo)
--shape at self origin
lg.circle("fill",self.x, self.y, 5)
end
function newRock:Slide()
-- we want to get xans scale one time. This function is repeated until the rock state is changed.
la.play(slide)
self.x = self.x + (self.sSpeed * xan.drawVars.sx)
end
function newRock:Slam()
-- add to rock list. Maybe this can lead into an overflow mechanic. If you don't push hard enough the rocks will not fall. It's a good place to evaluate the state of the player.
self.state = "rest"
-- the main fill will be the game state machine so score will be global.
addPoints(self.value)
end
I like nonsense, it wakes up the brain cells. Fantasy is a necessary ingredient in living, It's a way of looking at life through the wrong end of a telescope. Which is what I do, And that enables you to laugh at life's realities.
- Dr. Seuss
- Dr. Seuss
Re: XAN in Love WIP -- Help Moving forward.
haha. ok that's working. I have to change some of the player to deal with the rocks table. But I think that will work out just fine. I'll update soon.
I like nonsense, it wakes up the brain cells. Fantasy is a necessary ingredient in living, It's a way of looking at life through the wrong end of a telescope. Which is what I do, And that enables you to laugh at life's realities.
- Dr. Seuss
- Dr. Seuss
Re: XAN in Love WIP -- Help Crawling to ALPHA!
Hey lovers and ranks!
Xan keeps on growing! Thanks for being a rocking dev community! Here's my most current version of Xan. I'm working in the last touches of the basic gameplay. And running into loads and loads of bugs.
But instead of asking for help on any specific fire I've coded up. Could you give my .love a try and just let me know the first thing that comes to the mind?
Thanks dudes. Continue on!. Oh that FrameBuffer effect looks very amazing. I can't wait till it's in the cloud.
I do have a serious question: does anyone know a good way to snap the rocks to a '7x7 grid. I'd like to do a color flash based on this array. I think it'd be smarter than teaching the rocks to form a nice neat pile.
Thoughts appreciated as always.
Xan keeps on growing! Thanks for being a rocking dev community! Here's my most current version of Xan. I'm working in the last touches of the basic gameplay. And running into loads and loads of bugs.
But instead of asking for help on any specific fire I've coded up. Could you give my .love a try and just let me know the first thing that comes to the mind?
Thanks dudes. Continue on!. Oh that FrameBuffer effect looks very amazing. I can't wait till it's in the cloud.
I do have a serious question: does anyone know a good way to snap the rocks to a '7x7 grid. I'd like to do a color flash based on this array. I think it'd be smarter than teaching the rocks to form a nice neat pile.
Thoughts appreciated as always.
- Attachments
-
- XAN_9810.love
- Xan has nothing to do with Zangief. From a game mechanic standpoint. I don't know about you ... I always had a hard time doing the full circle motion. I'm glad it was dumbed down. ..... This has been an official ramblegram. -AC
- (3.31 MiB) Downloaded 347 times
I like nonsense, it wakes up the brain cells. Fantasy is a necessary ingredient in living, It's a way of looking at life through the wrong end of a telescope. Which is what I do, And that enables you to laugh at life's realities.
- Dr. Seuss
- Dr. Seuss
Re: XAN in Love WIP -- Help Moving forward.
I 've never posted the controls?
ok...
press [Space] to make a rock.
right and left mouse to grab one close to you.
esc to quit .
ok...
press [Space] to make a rock.
right and left mouse to grab one close to you.
esc to quit .
I like nonsense, it wakes up the brain cells. Fantasy is a necessary ingredient in living, It's a way of looking at life through the wrong end of a telescope. Which is what I do, And that enables you to laugh at life's realities.
- Dr. Seuss
- Dr. Seuss
Re: XAN in Love WIP -- Help Moving forward.
ill try the game later.
snap_pos_x = int (pos_x / 7) * 7
by int i mean removing the decimal places. i think in lua there is math.floor () for rounding
ie like this
snap_pos_x = int (160 / 7) * 7
= int (22,8571429) * 7
= 22 * 7
=> 160 gets snapped to 154
try diving and multiplying:does anyone know a good way to snap the rocks to a '7x7 grid.
snap_pos_x = int (pos_x / 7) * 7
by int i mean removing the decimal places. i think in lua there is math.floor () for rounding
ie like this
snap_pos_x = int (160 / 7) * 7
= int (22,8571429) * 7
= 22 * 7
=> 160 gets snapped to 154
Who is online
Users browsing this forum: Amazon [Bot] and 5 guests