Share My Creation HyperBloX - Old Version

So here's my pong game:


[ Download Demo ] [ Google Play Link ]


I'm surprised it took me only two weeks to complete it, since all the code, graphics, sound and music were created by me.
Once again big thanks to Erel for supporting B4A almost 24/7 and to Informatix for his LibGDX support and tutorials.

B4X:
Code:        B4A 4.00
Libs:        LibGDX
Graphics:    Photoshop CS6
Sound:       http://www.bfxr.net
Music:       FL Studio 11
Human:       Bruno Silva
 

Attachments

  • b4a.jpg
    b4a.jpg
    40.7 KB · Views: 3,113
Last edited:

ilan

Expert
Licensed User
Longtime User
very nice... good luck with your new game...

i think the score and the level strings should be on the top, so it wont distract the eyes of the player...
 
Last edited:

wonder

Expert
Licensed User
Longtime User
very nice... good luck with your new game...

i think the score and the level strings should be on the top, so it wont distract the eyes of the player...
Thanks for the feedback!! :)
I followed your advice and changed the display_level_Y position to the top. I even added a cool new slide in/out animation.

Looks like I have to record another video and take new screenshots... :rolleyes:
 

walterf25

Expert
Licensed User
Longtime User
Thanks for the feedback!! :)
I followed your advice and changed the display_level_Y position to the top. I even added a cool new slide in/out animation.

Looks like I have to record another video and take new screenshots... :rolleyes:
Hey Wonder, I was "wondering" lol, if you could share your slide in/out animation for the screens, i'm trying to accomplish something similar, but thought if you would be so kind as to share your code i will really appreciate it.

Thanks,
Walter
 

wonder

Expert
Licensed User
Longtime User
Hey Walter!!

Sure, I'll be glad to share how I did it.
For this example, consider an object that starts hidden off screen at -10%y which will slide down to its target position of 15%y.

First let's set the object size (Width and Height), its initial position x,y and its target position x,y.
The initial position is the off screen position, the target position will be, well, your target position. :D
B4X:
'In the Sub Globals...

        Dim OBJECT_H  =  8%y As Float
        Dim OBJECT_W  =  (OBJECT_H * 228) / 59 As Float
        Dim OBJECT_iX =  50%x - (OBJECT_W / 2) As Float
        Dim OBJECT_iY = -10%y - (OBJECT_H / 2) As Float
        Dim OBJECT_tX =  50%x - (OBJECT_W / 2) As Float
        Dim OBJECT_tY =  15%y - (OBJECT_H / 2) As Float
        Dim OBJECT_X  =  OBJECT_iX As Float
        Dim OBJECT_Y  =  OBJECT_iY As Float


Now let's create the "Sliders" where 66%y is my arbitrary speed and lgdx.graphics.DeltaTime is the step.
B4X:
Sub Hide_OBJECT
        If OBJECT_Y > OBJECT_iY Then
            OBJECT_Y = OBJECT_Y - 66%y * lgdx.graphics.DeltaTime
        Else
            OBJECT_Y = OBJECT_iY
        End If
End Sub

Sub Show_OBJECT
        If OBJECT_Y < OBJECT_tY Then
            OBJECT_Y = OBJECT_Y + 66%y * lgdx.graphics.DeltaTime
        Else
            OBJECT_Y = OBJECT_tY
        End If
End Sub


All we have to do now is call the subroutines as needed in a (the) main cycle, for example Sub LG_RENDER
B4X:
'In Sub LG_Render...
    Batch.Begin
        If This_OBJECT_Should_Be_Visible = True Then
            Show_OBJECT
        Else
            Hide_OBJECT
        End If
        Batch.DrawRegion2(OBJECT, OBJECT_X, OBJECT_Y, OBJECT_W, OBJECT_H)
    Batch.End


I hope this helps, as you can see, it's pretty simple. :)
 

walterf25

Expert
Licensed User
Longtime User
Hey Walter!!

Sure, I'll be glad to share how I did it.
For this example, consider an object that starts hidden off screen at -10%y which will slide down to its target position of 15%y.

First let's set the object size (Width and Height), its initial position x,y and its target position x,y.
The initial position is the off screen position, the target position will be, well, your target position. :D
B4X:
'In the Sub Globals...

        Dim OBJECT_H  =  8%y As Float
        Dim OBJECT_W  =  (OBJECT_H * 228) / 59 As Float
        Dim OBJECT_iX =  50%x - (OBJECT_W / 2) As Float
        Dim OBJECT_iY = -10%y - (OBJECT_H / 2) As Float
        Dim OBJECT_tX =  50%x - (OBJECT_W / 2) As Float
        Dim OBJECT_tY =  15%y - (OBJECT_H / 2) As Float
        Dim OBJECT_X  =  OBJECT_iX As Float
        Dim OBJECT_Y  =  OBJECT_iY As Float


Now let's create the "Sliders" where 66%y is my arbitrary speed and lgdx.graphics.DeltaTime is the step.
B4X:
Sub Hide_OBJECT
        If OBJECT_Y > OBJECT_iY Then
            OBJECT_Y = OBJECT_Y - 66%y * lgdx.graphics.DeltaTime
        Else
            OBJECT_Y = OBJECT_iY
        End If
End Sub

Sub Show_OBJECT
        If OBJECT_Y < OBJECT_tY Then
            OBJECT_Y = OBJECT_Y + 66%y * lgdx.graphics.DeltaTime
        Else
            OBJECT_Y = OBJECT_tY
        End If
End Sub


All we have to do now is call the subroutines as needed in a (the) main cycle, for example Sub LG_RENDER
B4X:
'In Sub LG_Render...
    Batch.Begin
        If This_OBJECT_Should_Be_Visible = True Then
            Show_OBJECT
        Else
            Hide_OBJECT
        End If
        Batch.DrawRegion2(OBJECT, OBJECT_X, OBJECT_Y, OBJECT_W, OBJECT_H)
    Batch.End


I hope this helps, as you can see, it's pretty simple. :)
Thanks for the code Wonder, i'm working with multiple screens, i'm not sure if this will work with two different screens, i'm trying to port this class to B4A, as it is the only code i've found so far to do what i need to accomplish.

https://enplug.com/blog/animating-transitions-between-libgdx-screens-using-tweenengine

the only problem is that the TweenEngine Library does not have all the Accessors, and in this case i need to register a Spriteclass.

Thanks anyway!

cheers,
Walter
 

walterf25

Expert
Licensed User
Longtime User
How about if you slide the object behind the background of the second screen?
I'm not sure i understand what you mean by the Object, i'm using the screens class, lgscreen and lgScreenManager class, i don't seen any method in the SpriteBatch class that can do that.

Thanks,
Walter
 

wonder

Expert
Licensed User
Longtime User
An object can be anything, a texture, a sprite, an imageview, a panel, it doesn't matter. Since I'm still learning libGDX's black magic, I can't really help you with very specific code, but I think this sliding under the background method would work. To do so, you should draw the "object" before the background of the second screen.

We might need the wisdom of Informatix on this matter...
 

sorex

Expert
Licensed User
Longtime User
is gdx always taking the full canvas or can you put it in a panel?
 

wonder

Expert
Licensed User
Longtime User
is gdx always taking the full canvas or can you put it in a panel?
You can put it in a view (which I always do), for example like this:
B4X:
    'Initialize libGDX
    GLView = lGdx.InitializeView("LG")   
    Activity.AddView(GLView, 0%x, 0%y, 100%x, 100%y)
 

walterf25

Expert
Licensed User
Longtime User
You can put it in a view (which I always do), for example like this:
B4X:
    'Initialize libGDX
    GLView = lGdx.InitializeView("LG")  
    Activity.AddView(GLView, 0%x, 0%y, 100%x, 100%y)
Yes i'm doing it this way, but this won't really help when you're using multiple screens (screens class)

Anyhow, i think i've figured out a way to do it, i'm using a frame buffer to create a screen shot of one screen, then hiding that screen and placing the screenshot over the hidden screen, then adding an action to the screen shot to slide it out of the way, then i display the second screen and take a screen shot of that second screen and do that same thing, it may be a little over kill but that's what the tutorial i posted above is doing and it works great, i'm not done yet, i'll try to make a class from it, and post it when i'm done, hopefully it will help someone.

Thanks,
walter
 
Top