> Newcomers roadmap: from where to start learning Gideros "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
Guys, how to make classic smooth jump, that depends on how long we are holding the button? I'm experimenting with enterframe, but my jump height is fixed.
function hero:init()
self.isJumping=false
self.jumpSpeed=4
self.gravityPower=0.1
self:addEventListener(Event.ENTER_FRAME, function()if self.isJumping then
self:setY(self:getY()-self.jumpSpeed)
self.jumpSpeed-=self.gravityPower
if self.jumpSpeed<=-4then self.isJumping=false; self.jumpSpeed=4; self:setY(self.origY)endendend)endfunction hero:jump()if self.isJumping==falsethen
self.isJumping=true
self.jumpSpeed=4
self.origY=self:getY()end
end</pre>
> Newcomers roadmap: from where to start learning Gideros "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
Very odd.. when I look at my reply my code is truncated and I cannot see it in its entirety
Do others see the entire code above or is it truncated at 'elseif y'??
Here it is in plain text..
Hero = Core.class(Pixel)
function Hero:init(color, alpha, width, height) self:setAnchorPoint(0.5, 1.0) self:setPosition(160, 32)
self.position = {x = 160, y = 32} self.velocity = {x = 0, y = 0} self.gravity = {x = 0, y = 960}
self.jumping = false end
function Hero:jump() -- set hero jumping if not self.jumping then self.jumping = true local g = self.gravity g.y = -2000 end end
function Hero:fall() -- set hero falling local g = self.gravity g.y = 960 end
function Hero:ground() self.jumping = false end
function Hero:update(dt) local p, v, g = self.position, self.velocity, self.gravity local gy = g.y local vy = v.y + gy * dt local y = p.y + vy * dt if y >= 480 - 32 then -- stop hero falling out of world y = 480 - 32 vy = 0 self:ground() elseif y <= 32 then -- stop hero jumping out of world y = 32 vy = 0 end v.y = vy p.y= y self:setY(y) end
local hero = Hero.new(0x44aa88, 1, 32, 32)
-- update every frame local function onEnterFrameFunc(e) local dt = e.deltaTime hero:update(dt) end
local function onTouchBegin(e) e:stopPropagation() hero:jump() end
-- set hero falling local function onTouchEnd(e) e:stopPropagation() hero:fall() end
@antix it is truncated at 'elseif y' . Edit: < pre lang="lua"> < /pre> is not working. It is making the code whole again but in yellow format without highligt. < code> tag is also seems to be the same not working as it should work.
It is funny indeed because when i try to edit your comment i saw the whole code, but when i close and return again truncated. So it is obvious something wrong with < pre > command.
> Newcomers roadmap: from where to start learning Gideros "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
> Newcomers roadmap: from where to start learning Gideros "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
If you have 10 collision rectangles in your game then just use whatever but if you start to get a lot of collision rectangles bump is what you should use because it's fast and efficient and provides some in built collision responses.
> Newcomers roadmap: from where to start learning Gideros "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
Why does this line cause an error? How to make it work? (I've added Bump to project's plugin list, I'm using latest Gideros version)
local world=require("bump").newWorld()--causes errorlocal world=bump.newWorld()--causes error too
lvls/lvl1.lua:44: module 'bump' not found: no field package.preload['bump'] no file '.\bump.lua' no file '.\bump\init.lua' no file '.\_LuaPlugins_\bump.lua' no file '.\_LuaPlugins_\bump\init.lua' no file 'C:\Program Files (x86)\Gideros\lua\bump.lua' no file 'C:\Program Files (x86)\Gideros\lua\bump\init.lua' no file 'C:\Program Files (x86)\Gideros\bump.lua' no file 'C:\Program Files (x86)\Gideros\bump\init.lua' no file '.\bump.dll' no file 'C:\Program Files (x86)\Gideros\bump.dll' no file 'C:\Program Files (x86)\Gideros\loadall.dll' stack traceback: lvls/lvl1.lua:44: in function 'init' [string "property.lua"]:52: in function '__new' [string "property.lua"]:59: in function 'new' classes/scenemanager.lua:274: in function 'changeScene' main.lua:13: in main chunk
All these dll/lua files usually have to be added to the folder manually? Or it is a little bug in Gideros' installation package?
> Newcomers roadmap: from where to start learning Gideros "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
> Newcomers roadmap: from where to start learning Gideros "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
> Newcomers roadmap: from where to start learning Gideros "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
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
> Newcomers roadmap: from where to start learning Gideros "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
Comments
https://play.google.com/store/apps/developer?id=razorback456
мій блог по гідерос https://simartinfo.blogspot.com
Слава Україні!
Likes: oleg, SinisterSoft
Likes: antix, SinisterSoft
https://play.google.com/store/apps/developer?id=razorback456
мій блог по гідерос https://simartinfo.blogspot.com
Слава Україні!
update: I didn't add them to stage LOL
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
I'm experimenting with enterframe, but my jump height is fixed.
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
Likes: Apollo14
https://play.google.com/store/apps/developer?id=razorback456
мій блог по гідерос https://simartinfo.blogspot.com
Слава Україні!
Likes: Apollo14
Do others see the entire code above or is it truncated at 'elseif y'??
Here it is in plain text..
Hero = Core.class(Pixel)
function Hero:init(color, alpha, width, height)
self:setAnchorPoint(0.5, 1.0)
self:setPosition(160, 32)
self.position = {x = 160, y = 32}
self.velocity = {x = 0, y = 0}
self.gravity = {x = 0, y = 960}
self.jumping = false
end
function Hero:jump() -- set hero jumping
if not self.jumping then
self.jumping = true
local g = self.gravity
g.y = -2000
end
end
function Hero:fall() -- set hero falling
local g = self.gravity
g.y = 960
end
function Hero:ground()
self.jumping = false
end
function Hero:update(dt)
local p, v, g = self.position, self.velocity, self.gravity
local gy = g.y
local vy = v.y + gy * dt
local y = p.y + vy * dt
if y >= 480 - 32 then -- stop hero falling out of world
y = 480 - 32
vy = 0
self:ground()
elseif y <= 32 then -- stop hero jumping out of world
y = 32
vy = 0
end
v.y = vy
p.y= y
self:setY(y)
end
local hero = Hero.new(0x44aa88, 1, 32, 32)
-- update every frame
local function onEnterFrameFunc(e)
local dt = e.deltaTime
hero:update(dt)
end
local function onTouchBegin(e)
e:stopPropagation()
hero:jump()
end
-- set hero falling
local function onTouchEnd(e)
e:stopPropagation()
hero:fall()
end
stage:addEventListener(Event.TOUCHES_BEGIN, onTouchBegin)
stage:addEventListener(Event.TOUCHES_END, onTouchEnd)
stage:addEventListener(Event.ENTER_FRAME, onEnterFrameFunc)
stage:addChild(hero)
Likes: Apollo14
Edit:
< pre lang="lua"> < /pre> is not working. It is making the code whole again but in yellow format without highligt.
< code> tag is also seems to be the same not working as it should work.
why did not I know about it before?
https://play.google.com/store/apps/developer?id=razorback456
мій блог по гідерос https://simartinfo.blogspot.com
Слава Україні!
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
p. s. Why not just use function instead of Bump?
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
@Apollo14
обрізає
Likes: SinisterSoft
https://play.google.com/store/apps/developer?id=razorback456
мій блог по гідерос https://simartinfo.blogspot.com
Слава Україні!
If you have 10 collision rectangles in your game then just use whatever but if you start to get a lot of collision rectangles bump is what you should use because it's fast and efficient and provides some in built collision responses.
Likes: totebo
Can you pls share a quick code example for Gideros, from where to start?
Likes: oleg
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
Anyhoo.. There was an interesting thread a while ago and I mashed a load of collision related stuff into it..
http://giderosmobile.com/forum/discussion/6353/collision-with-any-object/p1
Likes: Apollo14
--для платформера достатньо цього
Creating a world
local world = bump.newWorld
Adding items to the world
world:add(item, x,y,w,h)
Moving an item in the world, with collision resolution
local actualX, actualY, cols, len = world:move(item, goalX, goalY, )
https://play.google.com/store/apps/developer?id=razorback456
мій блог по гідерос https://simartinfo.blogspot.com
Слава Україні!
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
https://play.google.com/store/apps/developer?id=razorback456
мій блог по гідерос https://simartinfo.blogspot.com
Слава Україні!
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
https://play.google.com/store/apps/developer?id=razorback456
мій блог по гідерос https://simartinfo.blogspot.com
Слава Україні!
Likes: oleg, Apollo14, vitalitymobile
Likes: antix, Apollo14, totebo
And I'm getting this error:
How to solve it?
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
Likes: Apollo14
https://deluxepixel.com
But there is next error. Some files are missing in the project folder.
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)