Android Example FREE Source Code's !

Hi all,

i have updated my webpage and decided to add a tutorial section.

My first tutorial is a simple calculator (+,-,*,/) there is a video tutorial incl. Source code on my site.

I will upload the project also here and you can go to my site to watch the video if you like.

link: www.sagital.net

Edit: File was updated, fixed few bugs (24/04/2015)

** all free sources from me are free for personal use only, you may not sell them or publish them on your site or any forum, they are meant to learn from them. By downloading them you agree!

calc1.jpg
 

Attachments

  • t1calc.zip
    3.7 KB · Views: 2,426
Last edited:

ilan

Expert
Licensed User

ilan

Expert
Licensed User
MySql+PHP (b4j/b4a/b4i)

here is a simple example of how to use mysql+php.
this example icludes 2 screens:

* Login Screen
* Data Preview Screen (Read,Delete,Edit,Count,Insert)

** all free sources from me are free for personal use only, you may not sell them or publish them on your site or any forum, they are meant to learn from them. By downloading them you agree!

screen1.jpg


screen2.jpg
 

Attachments

  • mysql_php.zip
    7.7 KB · Views: 1,299
Last edited:

ilan

Expert
Licensed User
here is an example how you can draw circles randomly without overlapping each other.

** all free sources from me are free for personal use only, you may not sell them or publish them on your site or any forum, they are meant to learn from them. By downloading them you agree!

B4J:

B4X:
#Region  Project Attributes
    #MainFormWidth: 600
    #MainFormHeight: 400
#End Region

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Dim c As Canvas
    Type crl(x As Float,y As Float,r As Int)
    Dim circle_list As List
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.SetFormStyle("UNIFIED")
    MainForm.Show
    c.Initialize("canvas")
    circle_list.Initialize
    MainForm.RootPane.AddNode(c,0,0,MainForm.RootPane.Width,MainForm.RootPane.Height)
    fill_circles(1000)
End Sub

Sub fill_circles(amount As Int)
    Dim overlap As Boolean
    circle_list.Clear
    Dim i As Int = 0

    Do Until i = amount
        Dim circle, old_crl As crl
        circle.r = Rnd(2,25)
        circle.x = Rnd(circle.r,MainForm.RootPane.Width-(circle.r*2))
        circle.y = Rnd(circle.r,MainForm.RootPane.Height-(circle.r*2))

        overlap = False
        For j = 0 To circle_list.Size - 1
            old_crl = circle_list.Get(j)
            If distance_x(circle.x,old_crl.x,circle.r+old_crl.r) And distance_y(circle.y,old_crl.y,circle.r + old_crl.r) Then
                overlap = True
                Exit
            End If
        Next

        If Not(overlap) Then
           c.DrawCircle(circle.x,circle.y,circle.r,fx.Colors.ARGB(100,Rnd(0,255),Rnd(0,255),Rnd(0,255)),True,0)
           circle_list.Add(circle)
           i = i + 1
        End If
    Loop
End Sub

Sub distance_x(x1 As Float,x2 As Float,r2 As Int) As Boolean
    Return(Abs(x1-x2)<r2)
End Sub

Sub distance_y(y1 As Float,y2 As Float,r2 As Int) As Boolean
    Return(Abs(y1-y2)<r2)
End Sub

and here is an example of a raining day in my car

B4X:
#Region  Project Attributes
    #MainFormWidth: 600
    #MainFormHeight: 400
#End Region

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Dim c As Canvas
    Type crl(x As Float,y As Float,r As Int)
    Dim circle_list As List
    Dim t1, wiper As Timer
    Dim wiperCD As Int = 80
    Dim deg As Double = -90
    Dim now_back As Boolean
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.SetFormStyle("UNIFIED")
    MainForm.Show
    c.Initialize("canvas")
    circle_list.Initialize
    MainForm.RootPane.AddNode(c,0,0,MainForm.RootPane.Width,MainForm.RootPane.Height)
    t1.Initialize("t1",50)
    t1.Enabled = True
    wiper.Initialize("wiper",10)
End Sub

Sub t1_tick
    'c.ClearRect(0,0,c.Width,c.Height)
    fill_circles(Rnd(10,25))
    wiperCD = wiperCD - 1
    If wiperCD < 0 Then wiper.Enabled = True
End Sub

Sub wiper_tick
    If deg > 90 Then now_back = True
    If now_back =  True Then deg = deg - 2 Else deg = deg + 2  

    If deg < -90 Then
        wiper.Enabled = False
        deg = -90
        wiperCD = 80
        now_back = False
    Else
        c.DrawRectRotated(MainForm.Width/2,0,20,MainForm.Height*2,fx.Colors.White,True,0,deg)  
    End If
End Sub

Sub fill_circles(amount As Int)
    Dim overlap As Boolean
    circle_list.Clear
    Dim i As Int = 0
 
    Do Until i = amount
        Dim circle, old_crl As crl
        circle.r = Rnd(2,25)
        circle.x = Rnd(circle.r,MainForm.RootPane.Width-(circle.r*2))
        circle.y = Rnd(circle.r,MainForm.RootPane.Height-(circle.r*2))

        overlap = False
        For j = 0 To circle_list.Size - 1
            old_crl = circle_list.Get(j)
            If distance_x(circle.x,old_crl.x,circle.r+old_crl.r) And distance_y(circle.y,old_crl.y,circle.r + old_crl.r) Then
                overlap = True
                Exit
            End If
        Next 
     
        If Not(overlap) Then
           c.DrawCircle(circle.x,circle.y,circle.r,fx.Colors.ARGB(100,Rnd(0,255),Rnd(0,255),Rnd(0,255)),True,0)
           circle_list.Add(circle)
           i = i + 1
        End If
    Loop
End Sub

Sub distance_x(x1 As Float,x2 As Float,r2 As Int) As Boolean
    Return(Abs(x1-x2)<r2)
End Sub

Sub distance_y(y1 As Float,y2 As Float,r2 As Int) As Boolean
    Return(Abs(y1-y2)<r2)
End Sub

wiper.jpg
 

Attachments

  • circle.jar
    308 KB · Views: 469
Last edited:

ilan

Expert
Licensed User
hallo b4a community, it has been a long time but i got a new surprise for you.

B4A MultiTouch Piano Example. You will need @agraham Gestures Lib to run this example.

Have fun :)

** all free sources from me are free for personal use only, you may not sell them or publish them on your site or any forum, they are meant to learn from them. By downloading them you agree!

piano_keys.jpg
 

Attachments

  • piano example 2.zip
    330.1 KB · Views: 999
Last edited:

ilan

Expert
Licensed User
hi again,

here you have a fireworks class that you can use in all b4x platforms (after making some minor changes)

have fun :) (and dont forget to like, if you like it of course :p)

** all free sources from me are free for personal use only, you may not sell them or publish them on your site or any forum, they are meant to learn from them. By downloading them you agree!

(Source is included in the zip file)

firegif.gif
 

Attachments

  • fireworks.zip
    2.4 KB · Views: 610
  • fireworks.jar
    315 KB · Views: 529
Last edited:

ilan

Expert
Licensed User
Hi ilan,, How to open the project in b4a? i didn't find a project file

Hi,

Its a b4j project but u can use the class module also in b4a. The code should be 90% the same. So it should not be to hard to convert it to b4a.
 

FernandoMassa

Member
Licensed User
Hi

This is an old project called "Sk8 - Skateboard". I have rebuild it again and improve the code to make it more simpler to understand (incl. comments)

I used AndyMc "Cloney Bird Example" and made this game. (Thanx AndyMc)

The file is a little bit large (1Mb) so you can download it from my site (tutorial will follow soon)

link: www.sagital.net/tutorials/sk8.rar

Have fun! :)

** all free sources from me are free for personal use only, you may not sell them or publish them on your site or any forum, they are meant to learn from them. By downloading them you agree!

View attachment 33653
sorry, I know that this post has been done for over 3 years, but would you have the sources of this game to make it available again?
thanks :)
 

ilan

Expert
Licensed User
sorry, I know that this post has been done for over 3 years, but would you have the sources of this game to make it available again?
thanks :)

I will try to make it using xui2d when i will find the time so u can run it on all b4x products.
 
Top