Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Platformer example [using bump] — Gideros Forum

Platformer example [using bump]

rrraptorrrraptor Member
edited December 2019 in Game & application design
Just want to share a simple platformer example :smile:
Code is not very well commented, because my english is not good enough :neutral:

https://github.com/MultiPain/gideros-platformer
+1 -1 (+9 / -0 )Share on Facebook

Comments

  • Nice example.
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
  • piepie Member
    Cool, does it use bump? I see there is bump.lua in the file list but I am on mobile right now. Bump is native since some gideros release ago :smile: I think you can remove that file and use the plugin. also, adding bump word in this topic will make it easier to find it later :smiley:

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
  • rrraptorrrraptor Member
    edited January 2018

    Nice example.

    Thanks.
    pie said:

    Cool, does it use bump?

    Yeah, it is.
    pie said:

    Bump is native since some gideros release ago

    Hmm...i missed that...
    pie said:

    adding bump word in this topic will make it easier to find it later

    Done o:)

    Edit: have some problems with native bump. I need custom response function for one-way platforms, and it looks like this:
    local slide, cross = bump.responses.slide, bump.responses.cross
    local oneWay = function(world, col, x, y, w, h, goalX, goalY, filter)
    	if col.normal.y < 0 and not col.overlaps then
    		col.didTouch = true
    		return slide(world, col, x, y, w, h, goalX, goalY, filter)
    	else
    		return cross(world, col, x, y, w, h, goalX, goalY, filter)
    	end
    end
     
    self.world:addResponse("oneWay", oneWay)
    But with native bump, i cant get access to cross and slide function.

    Likes: antix, pie

    +1 -1 (+2 / -0 )Share on Facebook
  • Thanks, I was thinking about to develop a platform game and I need to create some prototype first. You save me some time.
  • antixantix Member
    edited January 2018
    Nice one @rrraptor, I really like your solution to the one way platform issue :)

    Maybe @hgy29 can build this one into cBump :)

    Likes: hgy29

    +1 -1 (+1 / -0 )Share on Facebook
  • hgy29hgy29 Maintainer
    Yes, I certainly can add your custom response to native bump, One way platforms are so common with platformers that even original bump should have included it at first. i would call it platform instead of oneway though.
  • Just to say, love the way you've coded the movement. So easy. May use the good bits in my next game. :)
    My Gideros games: www.totebo.com
  • @hgy29 well, this is not my implementation) I found the solution on love2d forum. But kikito (bump dev) says:
    for moving one-way platforms, you will need a bit more (platforms will need to "push up" whatever is touching them when they are moving up)
    So the solution is a bit more complicated.
  • totebototebo Member
    edited January 2018
    I downloaded the demo from Github and tried to run it with the latest Gideros 2018.1.1. Got an error:
    ./Stuff/bump.lua:43: x must be a number, but was nil(a nil)
    stack traceback:
    	./Stuff/bump.lua:43: in function 'assertType'
    	./Stuff/bump.lua:54: in function 'assertIsRect'
    	./Stuff/bump.lua:617: in function 'add'
    	Stuff/Platformer.lua:10: in function 'init'
    	[string "property.lua"]:52: in function '__new'
    	[string "property.lua"]:46: in function '__new'
    	[string "property.lua"]:59: in function 'new'
    	Scenes/GameScene.lua:68: in function 'loadLevel'
    	Scenes/GameScene.lua:15: in function 'init'
    	[string "property.lua"]:52: in function '__new'
    	[string "property.lua"]:59: in function 'new'
    	main.lua:8: in main chunk
    I tried to require "cbump" instead of the Lua Bump, and then I get this error:
    Scenes/GameScene.lua:43: attempt to index field 'responses' (a nil value)
    stack traceback:
    	Scenes/GameScene.lua:43: in function 'setupWorld'
    	Scenes/GameScene.lua:12: in function 'init'
    	[string "property.lua"]:52: in function '__new'
    	[string "property.lua"]:59: in function 'new'
    	main.lua:8: in main chunk
    Would be great to get it working out of the box, to show people new to Gideros.
    My Gideros games: www.totebo.com
  • rrraptorrrraptor Member
    edited January 2018
    @totebo i fixed that already )) Order matters...
    See the commit
    https://github.com/MultiPain/gideros-platformer/commit/bf41948f59196a8f5790614cbeb4d0342cee2511
    or screenshot:


    It doesn't work with native bump, for some reason. I removed custom response function, fixed "Item ray must be added to the world before getting its rect" error, and now player just crushing...
    1.png
    720 x 108 - 11K
    1.png 11.4K
  • totebototebo Member
    edited January 2018
    Ok cool, halfway there! I also got that "item needs to be added" with Bump in my own game. Maybe it's a bug in the Gideros c version of Bump?
    My Gideros games: www.totebo.com
  • @rrraptor The reason I wanted to download the demo was to see if jump height can be controlled. As in, the longer you hold jump the higher you jump.
    My Gideros games: www.totebo.com
  • totebo said:

    jMaybe it's a bug in the Gideros c version of Bump?

    Yeah, in my case world:project(...) works in lua version without adding item to the world, but cbump requiring to do so.
    totebo said:

    jump height can be controlled

    Nope, it doesnt.

    Btw, this example will not work with native verion, becouse of custom response function.

    Likes: totebo

    +1 -1 (+1 / -0 )Share on Facebook
  • hgy29hgy29 Maintainer
    rrraptor said:


    So the solution is a bit more complicated.

    Sure, I used a custom filter instead for Arthur and additional game logic for moving platforms. But collision response would be a start anyway.
  • I didn't use any custom response for one way platforms, I just processed it in the collision filter.

    Likes: MoKaLux

    +1 -1 (+1 / -0 )Share on Facebook
  • MoKaLuxMoKaLux Member
    edited November 2022
    rrraptor said:

    totebo said:

    jMaybe it's a bug in the Gideros c version of Bump?

    Yeah, in my case world:project(...) works in lua version without adding item to the world, but cbump requiring to do so.
    Btw, this example will not work with native verion, because of custom response function.
    I think I would need this "custom response function" ability :p I implemented moving platforms, that works great on horizontal moving platforms but not if they move vertically :s
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • MoKaLux said:

    I think I would need this "custom response function" ability :p I implemented moving platforms, that works great on horizontal moving platforms but not if they move vertically :s

    Technically it is possible (using luaL_ref/luaL_unref), but requires alot of changes.
  • MoKaLuxMoKaLux Member
    edited November 2022
    (at) rrraptor bump.lua you are using (which I have included in my test platformer) and gideros cbump are not behaving the same at all :s
    I have two sample cases:
    - bump.lua, when I am on a vertical moving platform I can jump when the platform is either going up or down which is super cool :)
    - gideros cbump, when I am on a vertical moving platform I can only jump when the platform is going down :/

    - bump.lua collisionfilter doesn't work as expected, that is the last elseif statement is always executed even if it doesn't collide at all :o
    - gideros cbump collisionfilter works as expected :)

    It is a shame because I would need a mix of bump.lua and cbump :p
    I am investigating and trying to find where guderos cbump and bump.lua differ. I will also try to make a sample project to show exactly what I mean.

    Here is my collisionfilter function (pass through platforms work out of the box without custom collisions)
    self.collisionfilter = function(item, other)
    	-- "touch", "cross", "slide", "bounce"
    	if item.isplayer1 then
    		if other.isnme then return "bounce" -- NOT TESTED
    		elseif other.isground then return "slide" -- TESTS OK
    		elseif other.isladder then return "cross" -- TESTS OK
    		elseif other.isptpf then -- TESTS OK
    			if item.isdown then return "cross" end -- go down on key down pressed
    			if item.body.vy > 0 then -- going down
    				local itembottom = item.y + item.h
    				local otherbottom = other.y + 8 -- treshold magik XXX +2
    				if itembottom <= otherbottom then return "slide" end
    			end
    		elseif other.ismvpf then  -- TEST OK WITH BUMP.LUA
    			if item.body.vy > 0 then -- going down
    				local itembottom = item.y + item.h
    				local otherbottom = other.y + 8 -- treshold magik XXX
    				if itembottom <= otherbottom then return "slide" end
    			else
    				return "cross"
    			end
    		elseif other.isspring then -- TESTS OK WITH GIDEROS CBUMP
    			if item.body.vy >= 0 then -- going down
    				print("xxx", item.body.vy) -- IN BUMP.LUA THIS CODE IS ALWAYS EXECUTED!!!
    				return "bounce"
    			end
    		end
    	end
    end
    PEACE
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • MoKaLuxMoKaLux Member
    edited November 2022
    I thought I found it :# !
    bump.lua
    function World:check(item, goalX, goalY, filter)
    	filter = filter or defaultFilter
     
    	local visited = {[item] = true}
    --	local visitedFilter = function(itm, other) -- TYPO itm?
    	local visitedFilter = function(item, other)
    		if visited[other] then return false end
    --		return filter(itm, other) -- TYPO itm?
    		return filter(item, other)
    	end
    ...
    end
    but no :* to be continued :D
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • cbump Gideros is not the same as bump.lua :| I don't know how to fix :( but with Gideros there is always a way :p
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • MoKaLuxMoKaLux Member
    edited November 2022
    rrraptor said:

    Just want to share a simple platformer example :smile:
    Code is not very well commented, because my english is not good enough :neutral:

    https://github.com/MultiPain/gideros-platformer

    following Mister rrraptor's path I am proposing my bump (cbump) platformer :)
    Let me share with you a screenshot, github should follow soon God's willing o:)

    I will also post on itch.io to see how it behaves and hopefully have some of you guys feedback ;)

    Viva Gideros Studio c++ luau

    PS: sorry I couldn't work on c++ Qt lately (I hate them :s ) :p
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • Likes: E1e5en

    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
    +1 -1 (+1 / -0 )Share on Facebook
  • I am very interested in the ECS template and I have tried to use it and plan to do more. But I can't always decide for myself how correctly to break everything, how small. Here is an example of my splitting into character management systems (made on a different engine and with its own ECS implementation library).


    Here I have divided each state into a separate system, the movement is also divided into systems for acceleration, braking and movement. I proceeded from the rule: divide everything. On using a separate system for the state, I read here: https://www.richardlord.net/blog/ecs/finite-state-machines-with-ash.html .
    As a result, there are a lot of small pieces and it's probably better to combine some pieces anyway. Otherwise, it becomes difficult to control such a quantity.
    Beginner game developer:https://e1e5en.itch.io, Google Play
  • @E1e5en I am new to ECS, I have examined rrraptor's ECS project https://github.com/MultiPain/Gideros-tiny-ECS, I watched many videos explaining ECS plus read some articles about it. The way I do it right now:
    - entities have unique id
    - entities can have components
    - systems act on components (thus entities)

    Will try to post my take on ECS asap :s

    I don't use state machine yet because it seems I don't need it so far and that would complicate my code?!
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • There is nothing complicated in the template itself. This can be called functional programming, where independent functions (installed in a certain sequence) simply change data (components), depending on other data (components). And the systems (functions) that relate to the engine simply use data from the components and api of the engine. The very essence is simple, but a good organization of these components and the system is a headache.
    Therefore, it will be interesting to look at your solution. And the right decision will come only with experience, you need to practice using this template more. =)
    Beginner game developer:https://e1e5en.itch.io, Google Play
  • MoKaLux said:


    I don't use state machine yet because it seems I don't need it so far and that would complicate my code?!

    Perhaps it will not complicate it, but simply increase it. More precisely, it will increase the number of files/systems.

    Beginner game developer:https://e1e5en.itch.io, Google Play
  • E1e5en said:

    There is nothing complicated but a good organization of these components and the system is a headache.
    And the right decision will come only with experience =)

    That is exactly right, I try to find the right balance between all these myself and it much depends really on the type of project you have.
    Right now I am implementing the shooting part and I am figuring out whether to create an entity, a component and a system for it or none at all :/
    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
  • MoKaLuxMoKaLux Member
    edited December 2022
    new html5 test https://mokatunprod.itch.io/gideros-tests
    GH https://github.com/mokalux/PLATFORMER_CBUMP_TECS_20221101_wodt :)

    Please note: this is still WIP, my code may not please everybody :p , I tried to make it easy to "decrypt"

    should be working:
    - jump run walk shoot
    - nmes platforms
    - animations

    not implemented:
    - sounds
    - other type of nmes
    - the code can be simplified (merging the AIs)
    - no score, no player die
    - no optimisations
    - no delta time :o
    - no, no, no ... :D

    Let's see how far I can take it, I will create a new thread to not spam rrraptor's mailbox ;)

    Likes: E1e5en

    my growING GIDEROS github repositories: https://github.com/mokalux?tab=repositories
    +1 -1 (+1 / -0 )Share on Facebook
  • MoKaLux said:
    It's funny that on a moving platform he can only walk, not run. I understand that it was done on purpose, an interesting decision.

    Likes: MoKaLux

    Beginner game developer:https://e1e5en.itch.io, Google Play
    +1 -1 (+1 / -0 )Share on Facebook
Sign In or Register to comment.