Good luck, it looks like your most ambitious game yet.
Just out of interest, are you seeing increasing amounts of income now from your in game adverts? I am wanting to develop more games and would feel more motivated to do so if I knew I would start making some extra cash from them.
I like it a lot!
BTW, can I show you a little project I'm in?
It's almost the same idea
So.. how are you handling the terrain?
In mine, I have about 10 prefabs, drawn with Gimp an modelled with the physics editor tool. They are 30m width and I'm adding them one after another.
I really don't know another way to do it... maybe using tiles and quads?
So.. how are you handling the terrain?
In mine, I have about 10 prefabs, drawn with Gimp an modelled with the physics editor tool. They are 30m width and I'm adding them one after another.
I really don't know another way to do it... maybe using tiles and quads?
I'm using prismatic and revolute joints. I've followed this great tutorial.
That sounds great!this is also how i do it, i create about 16 screen's in gimp and then create the bodies with the physics body editor tool. then i add them with a loop to my game.
my game looks now a little bit different since the last video i added water as a sensor and parts falling down to it and start swim.
when i cross the bridge it will break at the end and i remove 1 distancejoint and the bridge fall down (really nice effect)
I do not know either.this is how i did it to but i think it is better to use a whelljoint and i cannot figure out how to set it
can you post the code for your prismatic joint defination?
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Car Body
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim escalaCoche As Int = 3
Dim bd As lgBox2DBodyDef
bd.Position.Set(18, 2)
bd.Type = World.BODYTYPE_Dynamic
Dim fd As lgBox2DFixtureDef
fd.Density = 5
fd.Friction = 0.8
fd.Restitution = 0.2
fd.filter.groupIndex = -1
cocheBody= World.CreateBody (bd)
Loader.AttachFixture(cocheBody,"coche",fd,escalaCoche)
cocheTextura.Initialize("body2.png")
cocheSprite.InitializeWithTexture(cocheTextura)
cocheSprite.SetSize(escalaCoche, escalaCoche * cocheSprite.Height / cocheSprite.Width)
Dim Origin As lgMathVector2
Origin = Loader.GetOrigin("coche", escalaCoche)
cocheSprite.SetOrigin(Origin.X, Origin.Y)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Axis
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim axleShape As lgBox2DPolygonShape
Dim V1, V2 As lgMathVector2
axleShape.SetAsBox(0.2,0.2)
Dim axleFixture As lgBox2DFixtureDef
axleFixture.Density = 0.5
axleFixture.Friction = 3
axleFixture.Restitution = 0.1
axleFixture.shape = axleShape
axleFixture.filter.groupIndex = -1
Dim axleBodyDef As lgBox2DBodyDef
axleBodyDef.Type = World.BODYTYPE_Dynamic
'Eje trasero
Dim punto As lgMathVector2
punto.Set(0.13* escalaCoche,0.045* escalaCoche)
axleBodyDef.position.Set2(cocheBody.getWorldPoint(punto))
Dim rearAxle As lgBox2DBody = World.createBody(axleBodyDef)
rearAxle.createFixture(axleFixture)
'Eje delantero
punto.Set(0.81* escalaCoche,0.045* escalaCoche)
axleBodyDef.position.Set2(cocheBody.getWorldPoint(punto))
Dim frontAxle As lgBox2DBody = World.createBody(axleBodyDef)
frontAxle.createFixture(axleFixture)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Wheels
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim escalaRuedas As Float = 1
texturaRuedas.Initialize("rueda.png")
Dim fd As lgBox2DFixtureDef
fd.Density = 5
fd.Friction = 5
fd.Restitution = 0.1
fd.filter.groupIndex = -1
Dim wheelBodyDef As lgBox2DBodyDef
wheelBodyDef.Type = World.BODYTYPE_Dynamic
wheelBodyDef.angularDamping = 1.0
Dim punto As lgMathVector2
'la trasera
punto.Set(0.13* escalaCoche,0.045* escalaCoche)
wheelBodyDef.position.Set2(cocheBody.getWorldPoint(punto))
rearWheel = World.CreateBody (wheelBodyDef)
Loader.AttachFixture(rearWheel,"rueda",fd,escalaRuedas)
'la delantera
punto.Set(0.81* escalaCoche,0.045* escalaCoche)
wheelBodyDef.position.Set2(cocheBody.getWorldPoint(punto))
frontWheel = World.CreateBody (wheelBodyDef)
Loader.AttachFixture(frontWheel,"rueda",fd,escalaRuedas)
'los sprites de las ruedas
For i=0 To 1
ruedasSprite(i).InitializeWithTexture(texturaRuedas)
ruedasSprite(i).SetSize(escalaRuedas, escalaRuedas * ruedasSprite(i).Height / ruedasSprite(i).Width)
Dim Origin As lgMathVector2
Origin = Loader.GetOrigin("rueda", escalaRuedas)
ruedasSprite(i).SetOrigin(Origin.X, Origin.Y)
Next
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Revolute Joints
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim punto As lgMathVector2
punto.Set(0,0)
Dim rearWheelRevoluteJointDef As lgBox2DRevoluteJointDef
Dim frontWheelRevoluteJointDef As lgBox2DRevoluteJointDef
rearWheelRevoluteJointDef.Initialize(rearWheel,rearAxle,rearWheel.GetWorldPoint(punto))
rearWheelRevoluteJointDef.enableMotor=True
rearWheelRevoluteJointDef.maxMotorTorque=70
rearWheelRevoluteJoint=World.CreateJoint(rearWheelRevoluteJointDef)
' Dim frontWheelRevoluteJointDef As lgBox2DRevoluteJointDef
Dim punto As lgMathVector2
punto.Set(0,0)
frontWheelRevoluteJointDef.Initialize(frontWheel,frontAxle,frontWheel.GetWorldPoint(punto))
frontWheelRevoluteJointDef.enableMotor=True
frontWheelRevoluteJointDef.maxMotorTorque=20
frontWheelRevoluteJoint =World.CreateJoint(frontWheelRevoluteJointDef)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Prismatic Joints
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim axlePrismaticJointDef As lgBox2DPrismaticJointDef
axlePrismaticJointDef.lowerTranslation = -0.3
axlePrismaticJointDef.upperTranslation = 0.05
axlePrismaticJointDef.enableLimit = True
axlePrismaticJointDef.enableMotor = True
' front axle
punto.Set(0,0)
Dim direccion As lgMathVector2
direccion.Set(-0.5,1)
direccion.nor
axlePrismaticJointDef.Initialize(cocheBody,frontAxle,frontAxle.GetWorldPoint(punto),direccion)
frontAxlePrismaticJoint = World.CreateJoint(axlePrismaticJointDef)
' rear axle
direccion.Set(0.5,1)
direccion.nor
axlePrismaticJointDef.Initialize(cocheBody,rearAxle,rearAxle.GetWorldPoint(punto),direccion)
rearAxlePrismaticJoint = World.CreateJoint(axlePrismaticJointDef)
That sounds great!
I do not know either.
BTW, are you using Fixed timestep in your Box2d games?
I mean the step used in Box2DLights demos, because some days ago I tested my game in a tablet that can go only 55 FPS and the game felt a bit slower...
Here you go:
B4X:'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Car Body '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Dim escalaCoche As Int = 3 Dim bd As lgBox2DBodyDef bd.Position.Set(18, 2) bd.Type = World.BODYTYPE_Dynamic Dim fd As lgBox2DFixtureDef fd.Density = 5 fd.Friction = 0.8 fd.Restitution = 0.2 fd.filter.groupIndex = -1 cocheBody= World.CreateBody (bd) Loader.AttachFixture(cocheBody,"coche",fd,escalaCoche) cocheTextura.Initialize("body2.png") cocheSprite.InitializeWithTexture(cocheTextura) cocheSprite.SetSize(escalaCoche, escalaCoche * cocheSprite.Height / cocheSprite.Width) Dim Origin As lgMathVector2 Origin = Loader.GetOrigin("coche", escalaCoche) cocheSprite.SetOrigin(Origin.X, Origin.Y) '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Axis '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Dim axleShape As lgBox2DPolygonShape Dim V1, V2 As lgMathVector2 axleShape.SetAsBox(0.2,0.2) Dim axleFixture As lgBox2DFixtureDef axleFixture.Density = 0.5 axleFixture.Friction = 3 axleFixture.Restitution = 0.1 axleFixture.shape = axleShape axleFixture.filter.groupIndex = -1 Dim axleBodyDef As lgBox2DBodyDef axleBodyDef.Type = World.BODYTYPE_Dynamic 'Eje trasero Dim punto As lgMathVector2 punto.Set(0.13* escalaCoche,0.045* escalaCoche) axleBodyDef.position.Set2(cocheBody.getWorldPoint(punto)) Dim rearAxle As lgBox2DBody = World.createBody(axleBodyDef) rearAxle.createFixture(axleFixture) 'Eje delantero punto.Set(0.81* escalaCoche,0.045* escalaCoche) axleBodyDef.position.Set2(cocheBody.getWorldPoint(punto)) Dim frontAxle As lgBox2DBody = World.createBody(axleBodyDef) frontAxle.createFixture(axleFixture) '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Wheels '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Dim escalaRuedas As Float = 1 texturaRuedas.Initialize("rueda.png") Dim fd As lgBox2DFixtureDef fd.Density = 5 fd.Friction = 5 fd.Restitution = 0.1 fd.filter.groupIndex = -1 Dim wheelBodyDef As lgBox2DBodyDef wheelBodyDef.Type = World.BODYTYPE_Dynamic wheelBodyDef.angularDamping = 1.0 Dim punto As lgMathVector2 'la trasera punto.Set(0.13* escalaCoche,0.045* escalaCoche) wheelBodyDef.position.Set2(cocheBody.getWorldPoint(punto)) rearWheel = World.CreateBody (wheelBodyDef) Loader.AttachFixture(rearWheel,"rueda",fd,escalaRuedas) 'la delantera punto.Set(0.81* escalaCoche,0.045* escalaCoche) wheelBodyDef.position.Set2(cocheBody.getWorldPoint(punto)) frontWheel = World.CreateBody (wheelBodyDef) Loader.AttachFixture(frontWheel,"rueda",fd,escalaRuedas) 'los sprites de las ruedas For i=0 To 1 ruedasSprite(i).InitializeWithTexture(texturaRuedas) ruedasSprite(i).SetSize(escalaRuedas, escalaRuedas * ruedasSprite(i).Height / ruedasSprite(i).Width) Dim Origin As lgMathVector2 Origin = Loader.GetOrigin("rueda", escalaRuedas) ruedasSprite(i).SetOrigin(Origin.X, Origin.Y) Next '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Revolute Joints '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Dim punto As lgMathVector2 punto.Set(0,0) Dim rearWheelRevoluteJointDef As lgBox2DRevoluteJointDef Dim frontWheelRevoluteJointDef As lgBox2DRevoluteJointDef rearWheelRevoluteJointDef.Initialize(rearWheel,rearAxle,rearWheel.GetWorldPoint(punto)) rearWheelRevoluteJointDef.enableMotor=True rearWheelRevoluteJointDef.maxMotorTorque=70 rearWheelRevoluteJoint=World.CreateJoint(rearWheelRevoluteJointDef) ' Dim frontWheelRevoluteJointDef As lgBox2DRevoluteJointDef Dim punto As lgMathVector2 punto.Set(0,0) frontWheelRevoluteJointDef.Initialize(frontWheel,frontAxle,frontWheel.GetWorldPoint(punto)) frontWheelRevoluteJointDef.enableMotor=True frontWheelRevoluteJointDef.maxMotorTorque=20 frontWheelRevoluteJoint =World.CreateJoint(frontWheelRevoluteJointDef) '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Prismatic Joints '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Dim axlePrismaticJointDef As lgBox2DPrismaticJointDef axlePrismaticJointDef.lowerTranslation = -0.3 axlePrismaticJointDef.upperTranslation = 0.05 axlePrismaticJointDef.enableLimit = True axlePrismaticJointDef.enableMotor = True ' front axle punto.Set(0,0) Dim direccion As lgMathVector2 direccion.Set(-0.5,1) direccion.nor axlePrismaticJointDef.Initialize(cocheBody,frontAxle,frontAxle.GetWorldPoint(punto),direccion) frontAxlePrismaticJoint = World.CreateJoint(axlePrismaticJointDef) ' rear axle direccion.Set(0.5,1) direccion.nor axlePrismaticJointDef.Initialize(cocheBody,rearAxle,rearAxle.GetWorldPoint(punto),direccion) rearAxlePrismaticJoint = World.CreateJoint(axlePrismaticJointDef)
I hope you understand it, it's a mix of spanish and english
It was my first use of Box2D, so maybe now I'd do it different (I started the catapult and this one at the same time, then I decided to focus on the catapult one as I tought it would be easier)
Indeed, Box2D is awesome! I think I will follow your path as well, Ilan.I dont think that i will make games in the future without using box2d + libgdx.
By the way, what kind of gravity do you have in your game, Earth gravity?
BTW, can I show you a little project I'm in?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?