Android Tutorial JumpingSmiley - GameView example III

Status
Not open for further replies.
This is another example of GameView: GameView - Create 2D Android games - Part I

This is a simple "jumping" game where the user controls the movement by tilting the device:

SS-2013-02-07_18.17.28.png


There are two types of objects: Smiley - the main object and Brick which represents a single brick.

When the smiley moves upwards the background moves downwards. Bricks that go out of the screen are removed. A new brick is added instead of each removed brick.

Some of the bricks are moving and some of the bricks shrink when the smiley bounces on them.

All the sizes are scaled based on the device screen size (using percentage units).

Currently the game never ends. You can change it by modifying Smiley.Tick sub.

I think that this example is simpler than the Asteroids example as there are less "moving parts".
 

Attachments

  • JumpingSmiley.zip
    27.7 KB · Views: 1,149
Last edited:

James Abalos

New Member
Not all code paths return a value.

Public Sub Tick As Boolean
mAnimator.vy = vy
Dim visible As Boolean = mAnimator.Tick(bd)
vy = 0
If Not(visible) Then
bd.Delete = True
Return True
End If
End Sub

//

Private Sub CreateBrick(y As Int) As Brick
Dim brck As Brick
Dim bd As BitmapData
Dim size As Float = Rnd(15%x, 25%x)
Dim x As Float = Rnd(0, 100%x - size)
bd.DestRect.Initialize(x, y, x + size, y + 2%y)
gv.BitmapsData.Add(bd)
Dim animator As SpriteAnimator
animator.Initialize
animator.width = size
animator.height = 2%y
Dim r As Rect
Dim bmp As Bitmap
brck.Initialize(bd, animator)
If Rnd(1, 5) = 4 Then
'disappearing brick
bmp = disappearBrickImage
brck.disappearing = True
Else
bmp = regularBrickImage
End If
animator.SetFrames(bd, Array As Rect(r), Array As Bitmap(bmp))

bricks.Add(brck)
If Rnd(1, 5) = 4 Then animator.vx = PerXToCurrent(Rnd(-12, 12) / 10)

End Sub
 
Status
Not open for further replies.
Top