Games XUI2D Angry Birds Example

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.
 

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:

Erel

Administrator
Staff member
Licensed User
New version released with hint points:



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:
B4X:
'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(0, 0)
       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 * 4, 1, 1) '<--- 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, True, 0))
       Next
   End If
End Sub
 

ilan

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

View attachment 74049
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:

Erel

Administrator
Staff member
Licensed User
Example updated.

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



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:
Top