Games XUI2D Angry Birds Example

Discussion in 'Game Development' started by Erel, Nov 6, 2018.

  1. Erel

    Erel Administrator Staff Member Licensed User



    Images and copyrights belong to Rovio Entertainment. This example is only used for educational purposes.

    Assets were taken from this open source project: https://github.com/sarveshchavan7/AngryBirds

    This is a minimal example based on Angry Birds game.

    Interesting points:

    - Unlike most other examples, the game fills the entire screen. The world height is set to 3 meters and the world width is set based on the device screen size.
    - The hook ropes are drawn with the new BitmapCreator async drawing methods.
    - The hook itself is made of two images. The bird passes between them. There were some issues with the antialiasing effect adding a semitransparent line to the front image. To fix it I've resized the images without antialiasing using BitmapCreator.
    - This game misses some features. Collisions do not damage the pigs. They just push them. If there is interest I can extend this example.

    The example is included in the examples pack.
     
    Informatix, JohnCody, amaxco and 15 others like this.
  2. Erel

    Erel Administrator Staff Member Licensed User

    wonder likes this.
  3. ilan

    ilan Expert Licensed User

    AWESOME!!

    Edit: i have just tested the .Jar file and i really like the result. i wonder how well it runs on ios. i must say that i see a very good progress in xui2d performance. i think it is ready for my first b4xGame.

    i am working on an b4i game using spritekit and 90% is already finished. i start thinking if i should switch to xui2d and make the game for both platform or finish it and make a new game using xui2d?! :confused:
     
    Last edited: Nov 6, 2018
    DonManfred likes this.
  4. Jmu5667

    Jmu5667 Well-Known Member Licensed User

    Amazing Work !!!!
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    New version released with hint points:

    [​IMG]

    I've used a nice trick to calculate the points. I've added another B2World (SimulationWorld) and it is only used to simulate the bird future movement:
    Code:
    'This code is similar to the code that moves the real bird.
    Private Sub RunSimulation (gs As X2GameStep)
       
    If gs.ShouldDraw Then
           SimulationBird.GravityScale = 
    0
           SimulationBird.LinearVelocity = X2.CreateVec2(
    00)
           
    For i = 1 To 20
               
    Dim vec As B2Vec2 = HookCenter.Body.Position.CreateCopy
               vec.SubtractFromThis(SimulationBird.Position)
               
    Dim angle As Float = ATan2(vec.Y, vec.X)
               
    If SimulationBird.Position.X < HookCenter.Body.Position.X Then
                   
    Dim length As Float = vec.Length
                   
    Dim force As B2Vec2 = X2.CreateVec2(Cos(angle), Sin(angle))
                   force.MultiplyThis(
    1.5 * length)
                   SimulationBird.ApplyForce(force, SimulationBird.Position)
               
    Else
                   SimulationBird.GravityScale = 
    1
               
    End If
               SimulationWorld.TimeStep(X2.TimeStepMs / 
    1000 * 411'<--- let the simulation play
               Dim v As B2Vec2 = X2.WorldPointToMainBC(SimulationBird.Position.X, SimulationBird.Position.Y)
               X2.LastDrawingTasks.Add(X2.MainBC.AsyncDrawCircle(v.X, v.Y, 
    10, HintBrush, True0))
           
    Next
       
    End If
    End Sub
     
  6. sz4t4n

    sz4t4n Member Licensed User

    if I use a lot of force to shoot then something strange happen :) ->

    angry3.gif
     
    amaxco likes this.
  7. Gunther

    Gunther Active Member Licensed User

    Tunnelling Effect from a very fast bullet!
     
    Last edited: Nov 6, 2018
  8. ilan

    ilan Expert Licensed User

    the reason for that is that you move the ball to fast and the collision detection breaks what you need to do is set the bird body property to "bullet" and that should do the job.
     
    Last edited: Nov 7, 2018
  9. Erel

    Erel Administrator Staff Member Licensed User

    Adding this line to CreateBird indeed fixes this issue:
    Code:
    b.Body.Bullet = True
    Note that it can only happen in B4J as the screen limits you on the mobile platforms.
     
    wonder likes this.
  10. Erel

    Erel Administrator Staff Member Licensed User

    Example updated.

    1. The pigs damage is tracked. Check the code in World_PostSolve.

    [​IMG]

    2. Added sounds.

    3. The number of attempts is tracked. My highscore is 2 (lower is better).

    4. There were several changes to X2 framework.

    Credit for the new images and sounds: https://github.com/dgkanatsios/AngryBirdsStyleGame
     
    Last edited: Nov 7, 2018
    Phayao, Jmu5667 and inakigarm like this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice