Games (rpg game example) client

Douglas Farias

Expert
Licensed User
Longtime User
Hello everyone, I'm looking for an example of rpg game for B4J and B4A, my focus first is for B4J.
I'm looking for an example game in this style

eulo10r-png.54020

gallery-jpg.54021



My idea is to make an online server for the client using TCP, so I'll list below some things I need in the example.

- Player (character) can move up, down, left, and right through the keyboard.
- Player (character) can move with mouse click (Where the user clicks on it to go it should go.)
- Camera following the character
- option to change camera zoom code
- I need 2 examples of maps obviously.
- The maps must be loaded from a txt or a map file (like the mario example of @wonder)

https://www.b4x.com/android/forum/threads/b4j-mario-collision-detection-prototype.59543/#post-375167
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111111111110000000000000000000000000000000000000000000000000000000000000001000000000000200000000000000002000000000000000000000000000000000100000000000220000000000000000000000000000000000000000000000000010000000000222000000000000000000000000000000000000000000000000001000000000222200000000000000220000000000000000000000000000000000100000002222220000000000000000000000000000000000000000000000000011111111111111000000000000000000022200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011001010001000000000000000000000000000000000000000000000000000001010101000100000000000000000000000000000000000022222000000000000110011100010000000000000000000000000000000000000000000000000000010100010101000000011111111111111110000000000000000000000000000001100001011100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000222222000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022222220000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002223232323222000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010100000000011111111111111111111000000000000000000000000000000011011000000001300000000000000000000000000000000000000000000000011101110000000100000000100000000000000000000000000000000011111111111111111111111111111111111111111111111100011111111111111111111111111111111111111111111111111111111111110001111111111111
0: grass
1: stone
2: clay
3: wood
etc...
- I need the character to collide with rocks, water, etc ... (like map above, If the character tries to go to the stone (1) it is blocked)
- I need the position of the character, x and y when he moves
- Up, down, right and left walking animation
- Example of one or more enemy´s on map, it must move in circles or something like that (Need to detect if my character is close and if it is clicking on it, as if it were to simulate an attack)



All code should be as clean, clear and simple as possible, really the most simplified and easy to understand.

The images (assets) can be any one, as long as they are similar to the images above.

The payment will be via paypal.

I am waiting for any offer, whoever is interested and knows what I asked for above, just call me in private and we value the work.

I'll need more work later on in this game, this is just the beginning.

Sorry to post this here but the chance of this post being viewed in the games area is higher than in the Job Offers area

Thx
 

Attachments

  • EulO10r.png
    EulO10r.png
    75.4 KB · Views: 540
  • gallery.jpg
    gallery.jpg
    93.7 KB · Views: 487
Last edited:

ilan

Expert
Licensed User
Longtime User
If i remember correct there should be an example of an rpg game from @Informatix. I think it was done with acclerated surface.

Anyway i would recommend you learn the basics of box2d and do it by yourself. It should not be very hard to do such a game but it will need lot of time so it may be very expensive to let someone else do it for you.
 

Douglas Farias

Expert
Licensed User
Longtime User
If i remember correct there should be an example of an rpg game from @Informatix. I think it was done with acclerated surface.

Anyway i would recommend you learn the basics of box2d and do it by yourself. It should not be very hard to do such a game but it will need lot of time so it may be very expensive to let someone else do it for you.
i need to b4j first, can u make this for B4J? like mario of @wonder

if yes, how much it will cost?


thx
 

ilan

Expert
Licensed User
Longtime User
i need to b4j first, can u make this for B4J? like mario of @wonder

if yes, how much it will cost?


thx

making a game needs a lot of time especially such a game as rpg game.
but why is it important for you to have it like wonder did?

why not use tiled or any other app and create your map with objects and use it in your game. it is much more user friendly like this. you can easily move objects and redraw your level.

for creating levels i would use tiled
for the game engine i would use libgdx
for the physics (collisions with objects like rocks,...) i would use box2d

but again there are a lot of stuff to take in count so it is not simple.
my pixel knight game took me 3 weeks (first version with 12 levels) but i worked on it full time (about 8-10h per day)

if you have only 2-3 hours in a day such a game can easily take 3 month.

after the first level and all condition it will be simpler but you still need to take a lot of stuff in count.

just to give you a small taste, this is ONLY the collisions Sub for my Pixel Knight game:

B4X:
Sub Box2D_BeginContact(Contact As lgBox2DContact)
    Dim thisContact As typContact
    thisContact.Body1 = Contact.FixtureA.Body
    thisContact.Body2 = Contact.FixtureB.Body
  
    If Contact.FixtureA.Body.UserData = Null Or _
    Contact.FixtureB.Body.UserData = Null Then Return
  
    If Contact.FixtureA.Body.UserData Is objcor And Contact.Fixtureb.Body.UserData Is objcor Then
        Dim objcor1 As objcor = thisContact.Body1.UserData
        Dim objcor2 As objcor = thisContact.Body2.UserData
      
        If objcor1.name.Contains("lift") And thisContact.Body2 = player Or objcor2.name.Contains("lift") And thisContact.Body1 = player Then
            Dim liftb As lgBox2DBody
            If player = thisContact.Body1 Then liftb = thisContact.Body2 Else liftb = thisContact.Body1
            onlift = True
            liftonBody = liftb
            Dim objc As objcor = liftb.UserData
            Dim objc2 As objcor = player.UserData
            objc2.speed = objc.speed
            objc2.horizontal = objc.horizontal
        else if objcor1.name = "train" And thisContact.Body2 = player Or objcor2.name = "train" And thisContact.Body1 = player Then
            If trainstop = False Then
                Dim trainb As lgBox2DBody
                If player = thisContact.Body1 Then trainb = thisContact.Body2 Else trainb = thisContact.Body1
                ontrain = True
                trainbody = trainb
                Dim LeftWheelJoint As lgBox2DRevoluteJoint = Joint_arr.Get(0)
                Dim RightWheelJoint As lgBox2DRevoluteJoint = Joint_arr.Get(1)
                If LeftWheelJoint.isMotorEnabled = False Then LeftWheelJoint.enableMotor(True)
                If RightWheelJoint.isMotorEnabled = False Then RightWheelJoint.enableMotor(True)              
            End If  
        else If objcor1.name = ("coin") And thisContact.Body2 = player Or objcor2.name = ("coin") And thisContact.Body1 = player Then
            If thisContact.Body2 = player Then
                Dim objco1 As objcor = thisContact.Body1.UserData
                If objco1.hit = False Then
                    If soundon = 1 Then coinsound.Play2(0.3)
                    objco1.hit = True
                End If  
            Else
                Dim objco1 As objcor = thisContact.Body2.UserData
                If objco1.hit = False Then   
                    If soundon = 1 Then coinsound.Play2(0.3)
                    objco1.hit = True                  
                End If
            End If  
            cointint = cointint + 1  
        else If objcor1.name = ("coin2") And thisContact.Body2 = player Or objcor2.name = ("coin2") And thisContact.Body1 = player Then
            If thisContact.Body2 = player Then
                Dim objco1 As objcor = thisContact.Body1.UserData
                If objco1.hit = False Then
                    If soundon = 1 Then coinsound.Play2(0.3)
                    objco1.hit = True
                End If  
            Else
                Dim objco1 As objcor = thisContact.Body2.UserData
                If objco1.hit = False Then   
                    If soundon = 1 Then coinsound.Play2(0.3)
                    objco1.hit = True                  
                End If
            End If  
            cointint = cointint + 25              
        else if objcor1.name = "info" And thisContact.Body2 = player Or objcor2.name = "info"  And thisContact.Body1 = player Then
            If objcor1.name = "info" Then
                infoint = objcor1.key
            Else
                infoint = objcor2.key
            End If      
            drawshield = True
            drawshieldFadeOUT = False
            drawshieldFadeCD = 0
        else if thisContact.Body1 = player And thisContact.Body2 = checkpoint Or thisContact.Body2 = player And thisContact.Body1 = checkpoint Then
            If checkpointhit = False Then
                checkpointhit = True
                If soundon = 1 Then checkpointsound.Play2(0.5)
            End If  
        else If thisContact.Body1 = player And thisContact.Body2 = gate Or thisContact.Body2 = player And thisContact.Body1 = gate Then
            Dim gateobj As objcor = gate.UserData
            If gateobj.hit = True And gateobj.exitnow = False Then
                gateobj.exitnow = True
                goleft = False
                goright = False
                firedown = False
                injump = False
                player.setLinearVelocity2(player.getLinearVelocityFromWorldPoint(player.WorldCenter).x/2,player.getLinearVelocityFromWorldPoint(player.WorldCenter).y)
            End If                  
        else if objcor1.name = "spikes" And thisContact.Body2 = player Or objcor2.name = "spikes"  And thisContact.Body1 = player Then
            If medead = False Then
                killplayer
                changeplayertosensor      
            End If
        else if objcor1.name = "key" And thisContact.Body2 = player Or objcor2.name = "key"  And thisContact.Body1 = player Then
            Dim keycor As objcor
            If thisContact.Body1 = player Then
                keycor = thisContact.Body2.UserData
                If keycor.key = "1" Then
                    keycor.key = "2"
                    camerafollow = gate
'                    cameragofast = True
                    turnon_elevators
                    waitforgate = True
                End If   
            Else
                keycor = thisContact.Body1.UserData
                If keycor.key = "1" Then
                    keycor.key = "2"
                    camerafollow = gate
'                    cameragofast = True
                    turnon_elevators
                    waitforgate = True              
                End If   
            End If  
        else if  objcor1.name = "sticky" And thisContact.Body2 = player Or objcor2.name = "sticky" And thisContact.Body1 = player Then      
            onsticky = True              
        else if objcor1.name = "enemy" And thisContact.Body2 = player Or objcor2.name = "enemy" And thisContact.Body1 = player Then      
            If medead = False Then
                killplayer
                changeplayertosensor              
            End If  
        else if objcor1.name = "fallstone" And thisContact.Body2 = player Or objcor2.name = "fallstone" And thisContact.Body1 = player Then      
            Dim fallstone As lgBox2DBody
            If thisContact.Body2 = player Then fallstone = thisContact.Body1 Else fallstone = thisContact.Body2
            Dim fallstoneobj As objcor = fallstone.UserData
            If fallstone.getLinearVelocityFromWorldPoint(fallstone.WorldCenter).y < -2 Then
                If medead = False Then
                    fallstoneobj.hit = True
                    killplayer
                    changeplayertosensor  
                    If soundon = 1 Then    fallstonesound.Play2(0.6)  
                    Worldshakenow = True
                    shakeCD = 20
                End If
            End If
        else if objcor1.name = "fallstone" And objcor2.name    = "ground" Or objcor2.name = "fallstone" And objcor1.name = "ground" Then  
            Dim fallstoneobj As objcor
            If objcor2.name    = "ground" Then fallstoneobj = objcor1 Else fallstoneobj = objcor2
            If fallstoneobj.hit = False Then
                fallstoneobj.hit = True
                If soundon = 1 Then    fallstonesound.Play2(0.6)
                Worldshakenow = True
                shakeCD = 20          
            End If  
        Else if objcor1.name = "enemybullet" And thisContact.Body2 = player Or objcor2.name = "enemybullet" And thisContact.Body1 = player Then      
            If thisContact.Body2 = player Then
                Dim bullet As objcor = thisContact.Body1.UserData
                bullet.hit = True          
            Else
                Dim bullet As objcor = thisContact.Body2.UserData
                bullet.hit = True
            End If
            If medead = False Then
                killplayer
                changeplayertosensor      
            End If
        else if objcor1.name = "enemybullet" And thisContact.Body2 <> player Or objcor2.name = "enemybullet" And thisContact.Body1 <> player Then
            If objcor1.key = "fireball" Or objcor2.key = "fireball" Then
                If objcor1.key = "fireball" Then
                    If objcor2.name = "lava" Then
                        If objcor2.hit = False Then
                            objcor2.hit = True
                            objcor2.xbody = "lava"
                        End If  
                    else if objcor2.name = "fireball" Then
                        If objcor1.hit = False Then
                            objcor1.hit = True
                        End If
                    End If  
                else If objcor2.key = "fireball" Then
                    If objcor1.name = "lava" Then
                        If objcor1.hit = False Then
                            objcor1.hit = True
                            objcor1.xbody = "lava"
                        End If  
                    else if objcor1.name = "fireball" Then
                        If objcor2.hit = False Then
                            objcor2.hit = True
                        End If
                    End If  
                End If  
            else If objcor1.name = "wall" Or objcor1.name = "ground" Or objcor1.name = "movingwall" Or objcor1.name = "spikes" Or objcor1.name = "sticky" Or objcor1.name = "groundvis" Or objcor1.name = "fallground" Or objcor1.name = "lift" Or objcor1.name = "fallstone" Or objcor2.name = "wall" Or objcor2.name = "ground" Or objcor2.name = "movingwall" Or objcor2.name = "spikes"  Or objcor2.name = "sticky" Or objcor2.name = "groundvis" Or objcor2.name = "fallground" Or objcor2.name = "lift" Or objcor2.name = "fallstone" Then
                If objcor1.name = "enemybullet" Then
                    Dim bullet As objcor = thisContact.Body1.UserData
                    bullet.hit = True  
                Else
                    Dim bullet As objcor = thisContact.Body2.UserData
                    bullet.hit = True
                End If      
            End If  
        else if objcor1.name = "enemy" And objcor2.name = "train" Or objcor2.name = "enemy" And objcor1.name = "train" Then  
            If objcor2.name = "train" Then
                If objcor1.key = "stone" Then
                    If trainstop = False Then
                        If Abs(trainbody.getLinearVelocityFromWorldPoint(trainbody.WorldCenter).x) < 1 Then
                            trainstop = True
                            Dim LeftWheelJoint As lgBox2DRevoluteJoint = Joint_arr.Get(0)
                            Dim RightWheelJoint As lgBox2DRevoluteJoint = Joint_arr.Get(1)
                            LeftWheelJoint.enableMotor(False)
                            RightWheelJoint.enableMotor(False)
                        End If
                    End If
                End If  
            Else
                If objcor2.key = "stone" Then
                    If trainstop = False Then
                        If Abs(trainbody.getLinearVelocityFromWorldPoint(trainbody.WorldCenter).x) < 1 Then
                            trainstop = True
                            Dim LeftWheelJoint As lgBox2DRevoluteJoint = Joint_arr.Get(0)
                            Dim RightWheelJoint As lgBox2DRevoluteJoint = Joint_arr.Get(1)
                            LeftWheelJoint.enableMotor(False)
                            RightWheelJoint.enableMotor(False)
                        End If
                    End If
                End If  
            End If
        else if objcor1.name = "water" And thisContact.Body2 = player Or objcor2.name = "water" And thisContact.Body1 = player Then      
            Dim waterbody As lgBox2DBody
            If thisContact.Body2 = player Then waterbody = thisContact.Body1 Else waterbody = thisContact.Body2
            Dim waterobj As objcor = waterbody.UserData
            If waterobj.hit = False Then waterobj.hit = True
            inwater = True
        else if objcor1.name = "lava" And thisContact.Body2 = player Or objcor2.name = "lava" And thisContact.Body1 = player Then      
            Dim lavabody As lgBox2DBody
            If thisContact.Body2 = player Then lavabody = thisContact.Body1 Else lavabody = thisContact.Body2
            Dim lavaobj As objcor = lavabody.UserData
            If lavaobj.hit = False Then
                 lavaobj.hit = True
                 lavaobj.xbody = "player"
            End If
            If medead = False Then
                killplayer
                changeplayertosensor      
            End If
        else If objcor1.name = "fallground" And thisContact.Body2 = player Or objcor2.name = "fallground" And thisContact.Body1 = player Then  
            Dim fallg As lgBox2DBody
            If player = thisContact.Body2 Then fallg = thisContact.Body1 Else fallg = thisContact.Body2
            Dim fallgobj As objcor = fallg.UserData
            If fallgobj.hit = False Then
                fallgobj.hit = True
                fallg.GravityScale = 0.5 'set gravity to falling ground!
                fallgroundtouched = True
            End If  
        else if objcor1.name = "groundsh" And thisContact.Body2 = player Or objcor2.name = "groundsh" And thisContact.Body1 = player Then
            If thisContact.Body2 = player Then
                If objcor1.key = "right" Then
                    player.setLinearVelocity2(speed*0.8,player.getLinearVelocityFromWorldPoint(player.WorldCenter).y)
                Else
                    player.setLinearVelocity2(-speed*0.8,player.getLinearVelocityFromWorldPoint(player.WorldCenter).y)  
                End If  
            Else
                If objcor2.key = "right" Then
                    player.setLinearVelocity2(speed*0.8,player.getLinearVelocityFromWorldPoint(player.WorldCenter).y)
                Else
                    player.setLinearVelocity2(-speed*0.8,player.getLinearVelocityFromWorldPoint(player.WorldCenter).y)  
                End If  
            End If
            ongroundsh = True
        else If objcor1.name = "velocity" And thisContact.Body2 = player Or objcor2.name = "velocity" And thisContact.Body1 = player Then  
            Dim velobjcor As objcor
            If thisContact.Body2 = player Then velobjcor = thisContact.Body1.UserData Else velobjcor = thisContact.Body2.UserData
            If velobjcor.horizontal = 1 Then
                autovelocityON = True
            Else
                If autovelocityON = True Then
                    autovelocityON = False
                    goright = False                  
                End If  
            End If  
        else If objcor1.name = "bottle" And thisContact.Body2 = player Or objcor2.name = "bottle" And thisContact.Body1 = player Then
            Dim bottleobjcor As objcor
            If thisContact.Body2 = player Then bottleobjcor = thisContact.Body1.UserData Else bottleobjcor = thisContact.Body2.UserData
            If bottleobjcor.hit = False Then
                bottleobjcor.hit = True
            End If  
        else if objcor1.name = "buttonaction" And thisContact.Body2 = player Or objcor2.name = "buttonaction" And thisContact.Body1 = player Then
            Dim btnact As lgBox2DBody
            If thisContact.Body2 = player Then btnact = thisContact.Body1 Else btnact = thisContact.Body2
            Dim btncor As objcor = btnact.UserData
            If btncor.hit = False Then
                If player.Position.y-(20/scaleY) > btnact.Position.y Then
                    btncor.hit = True
                    movingwallint = btncor.frame
                    If soundon = 1 Then opensound.Play2(0.4)
                End If      
            End If  
        else if objcor1.name = "knife" And objcor2.name = "knifestation" Or objcor2.name = "knife" And objcor1.name = "knifestation" Then
            If objcor1.name = "knife" Then
                If objcor2.shoot = 0 Then 'knife hit reciver
                    objcor1.hit = True
                End If
            Else
                If objcor1.shoot = 0 Then 'knife hit reciver
                    objcor2.hit = True
                End If              
            End If  
        else If objcor1.name = "knife" And thisContact.Body2 = player Or objcor2.name = "knife" And thisContact.Body1 = player Then
            If medead = False Then
                killplayer
                changeplayertosensor      
            End If
        Else If objcor1.name = "rails" And thisContact.Body2 = player Or objcor2.name = "rails" And thisContact.Body1 = player Then
            If medead = False Then
                killplayer
                changeplayertosensor  
            End If
        else If objcor1.name = "JointB" And thisContact.Body2 = player Or objcor2.name = "JointB" And thisContact.Body1 = player Then   
            Dim jbody As lgBox2DBody
            If player = thisContact.Body2 Then jbody = thisContact.Body1 Else jbody = thisContact.Body2
            Dim jbodycor1 As objcor = jbody.UserData
            If jbodycor1.key = "enemy" Then
                If medead = False Then
                    killplayer
                    changeplayertosensor  
                End If
            Else
                'do nothing just a dnamic body with swing simulation
            End If
        End If  
     else if Contact.FixtureA.Body.UserData Is sword And Contact.Fixtureb.Body.UserData Is objcor Or Contact.Fixtureb.Body.UserData Is sword And Contact.Fixturea.Body.UserData Is objcor Then
         If Contact.FixtureA.Body.UserData Is sword Then
            Dim cor1 As objcor = Contact.Fixtureb.Body.UserData
            If cor1.name = "wall" Or cor1.name = "ground" Or cor1.name = "movingwall" Or cor1.name = "spikes" Or cor1.name.Contains("canon") Then
                Dim sword1 As sword = Contact.FixtureA.Body.UserData
                If sword1.hit = False Then
                    sword1.hit = True
                    If soundon = 1 Then    hitsound.Play2(0.5)                  
                End If
            else if cor1.name = "treasure" Then
                If cor1.key = "0" Then
                    cor1.key = "1"
                    Dim sword1 As sword = Contact.FixtureA.Body.UserData
                    If sword1.hit = False Then
                        sword1.hit = True
                        If soundon = 1 Then    hitsound.Play2(0.5)
                    End If
                End If
            else if cor1.name = "enemy" Then
                If cor1.hit = False Then
                    Dim sword1 As sword = Contact.FixtureA.Body.UserData
                    If cor1.key <> "superspike" And cor1.key <> "blade" And cor1.key <> "stone" And cor1.key <> "axe" Then
                        If sword1.hit = False Then
                            cor1.hitallowed = cor1.hitallowed - selectedSword.swordPower
                            cor1.redCD = 10
                            sword1.hit = True
                            If soundon = 1 Then    hitsound.Play2(0.5)                          
                        End If  
                        If cor1.hitallowed < 1 Then cor1.hit = True      
                    else If sword1.hit = False Then
                        sword1.hit = True      
                        If soundon = 1 Then    hitsound.Play2(0.5)                      
                    End If
                End If  
            else if cor1.name = "JointB"  Then
                Dim sword1 As sword = Contact.FixtureA.Body.UserData
                If sword1.hit = False Then
                    sword1.hit = True              
                    Dim vec2 As lgMathVector2
                    If sword1.direction = 1 Then
                        vec2.Set(4,0)
                    Else
                        vec2.Set(-4,0)
                    End If  
                    Contact.Fixtureb.Body.applyLinearImpulse(vec2,Contact.Fixtureb.Body.WorldCenter,True)          
                    If soundon = 1 Then    hitsound.Play2(0.5)                  
                End If
            else if cor1.name = "box" Then
                Dim sword1 As sword = Contact.FixtureA.Body.UserData
                If sword1.hit = False Then
                    sword1.hit = True
                    Dim vec2 As lgMathVector2
                    If sword1.direction = 1 Then
                        vec2.Set(2.5,0)
                    Else
                        vec2.Set(-2.5,0)
                    End If  
                    Contact.Fixtureb.Body.applyLinearImpulse(vec2,Contact.Fixtureb.Body.WorldCenter,True)
                    If soundon = 1 Then    hitsound.Play2(0.5)                      
                End If
            else if cor1.name = "fallstone" Then
                Dim sword1 As sword = Contact.FixtureA.Body.UserData
                If sword1.hit = False Then
                    cor1.hitallowed = cor1.hitallowed - selectedSword.swordPower
                    sword1.hit = True  
                End If                              
                If soundon = 1 Then    hitsound.Play2(0.5)                  
            End If   
        Else
            Dim cor1 As objcor = Contact.FixtureA.Body.UserData
            If cor1.name = "wall" Or cor1.name = "ground" Or cor1.name = "movingwall" Or cor1.name = "spikes" Or cor1.name.Contains("canon") Then
                Dim sword1 As sword = Contact.Fixtureb.Body.UserData
                sword1.hit = True
                If soundon = 1 Then    hitsound.Play2(0.5)
            else if cor1.name = "treasure" Then
                If cor1.key = "0" Then
                    cor1.key = "1"
                    Dim sword1 As sword = Contact.Fixtureb.Body.UserData
                    If sword1.hit = False Then
                        sword1.hit = True
                        If soundon = 1 Then    hitsound.Play2(0.5)                      
                    End If
                End If
            else if cor1.name = "enemy" Then
                If cor1.hit = False Then
                    Dim sword1 As sword = Contact.Fixtureb.Body.UserData
                    If sword1.hit = False Then
                        If cor1.key <> "superspike" And cor1.key <> "blade" And cor1.key <> "stone" And cor1.key <> "axe" Then
                            If sword1.hit = False Then
                                cor1.hitallowed = cor1.hitallowed - selectedSword.swordPower
                                cor1.redCD = 10
                                sword1.hit = True
                                If soundon = 1 Then    hitsound.Play2(0.5)  
                            End If  
                            If cor1.hitallowed < 1 Then cor1.hit = True  
                        else If sword1.hit = False Then
                            sword1.hit = True  
                            If soundon = 1 Then    hitsound.Play2(0.5)  
                        End If                   
                    End If
                End If  
            else if cor1.name = "JointB" Then
                Dim sword1 As sword = Contact.Fixtureb.Body.UserData
                If sword1.hit = False Then
                    sword1.hit = True
                    Dim vec2 As lgMathVector2
                    If sword1.direction = 1 Then
                        vec2.Set(4,0)
                    Else
                        vec2.Set(-4,0)
                    End If  
                    Contact.Fixturea.Body.applyLinearImpulse(vec2,Contact.Fixturea.Body.WorldCenter,True)
                    If soundon = 1 Then    hitsound.Play2(0.5)                      
                End If
            else if cor1.name = "box" Then
                Dim sword1 As sword = Contact.Fixtureb.Body.UserData
                If sword1.hit = False Then
                    sword1.hit = True
                    Dim vec2 As lgMathVector2
                    If sword1.direction = 1 Then
                        vec2.Set(2.5,0)
                    Else
                        vec2.Set(-2.5,0)
                    End If  
                    Contact.Fixturea.Body.applyLinearImpulse(vec2,Contact.Fixturea.Body.WorldCenter,True)
                    If soundon = 1 Then    hitsound.Play2(0.5)                      
                End If
            else if cor1.name = "fallstone" Then
                Dim sword1 As sword = Contact.Fixtureb.Body.UserData
                If sword1.hit = False Then
                    cor1.hitallowed = cor1.hitallowed - selectedSword.swordPower
                    sword1.hit = True
                End If
                If soundon = 1 Then    hitsound.Play2(0.5)                                  
            End If   
        End If
     End If
End Sub

you can think of how the rest look like :p
oh and this is only 1 part of the collision, i have also a sub of PreSolve and EndContact.
 
Last edited:

Douglas Farias

Expert
Licensed User
Longtime User
i can pay $300 for working example to >> B4J <<
As simple as possible
 

Douglas Farias

Expert
Licensed User
Longtime User
The offer increased to $ 500 (for b4j example working)
 

Douglas Farias

Expert
Licensed User
Longtime User
Offer closed, someone is already working on this, thank you.
 
Top