'-- class example two times
'
'---------------------- //
class myZooClass
pApe as long
method ABC(value as long)
pApe = value
end method
method ABC() as long
method = pApe
end method
end class
'test it
dim zoo as myZooClass
zoo.ABC = 6
print zoo.ABC ' 6
'---------------------- //
class AnimalClass
tiger as long
method paw(claws as long)
tiger= claws
end method
method paw() as long
method = tiger
end method
end class
'test it
dim cat as AnimalClass
cat.paw = 5
print "catpaw " +cat.paw ' 5
'
' two function examples, factorial, quattro
' -- example 1
Function factorial(x As Integer) As Integer
' This is a recursive function
' to find the factorial of an integer
If x = 1 Then
return 1
Else
return x * factorial(x-1)
End If
End Function
printy factorial(4) ' 24
pim num As Integer
num = 3
Printy "The factorial of " + num + " is " + str(factorial(num) )
' -- example 2
function quattro(i as pro) as pro
return i*4
end function
printy quattro(4) ' 16
' -- expl 1
' -- for...next
'
dim i as integer, height as integer
height = 5
FOR i = 1 to height
printy string(i, "*")
next
printy "after loop the value i has value " + i
'
'-- expl 2 do...loop
'
dim n as integer, even as integer
Do
n += 1
If n > 7 Then Exit Do
If n Mod 2 Then Continue Do
even += 1
Loop
Printy "even number: " + even
' simple calculation 2
' legend :
' dim = pim, dword = pro
' printy = print
' pstring = string
'
pim a,b,c,d as pro
a= 10 : b=20 : c=40 : d=a*b
printy a
printy d
pstring s = "Hello Batman " + a ' 10
printy s
pstring st = "Hello Spiderman " + d ' 200
printy st
pim k as float
k=2345.67 '2345.6699
printy k
' fictive code example only an idea for boundingbox for a cube m500 and m400
'
' This example serves for a moving the cube in discrete steps (e.g., one unit at a time)
' Movement logic for cube 500
if key_up_pressed then
moveCube500(0, 1) ' Move up one unit at a time
elseif key_down_pressed then
moveCube500(0, -1) ' Move down
elseif key_left_pressed then
moveCube500(-1, 0) ' Move left
elseif key_right_pressed then
moveCube500(1, 0) ' Move right
end if
int new_x, newy
' Function to move cube 500 and handle collision
sub moveCube500(int dx, int dy)
' Calculate new position
new_x = cube500_x + dx
new_y = cube500_y + dy
' Check for collision with cube 400
collision = BoundingBoxIntersect(new_x, new_y, cube_width, cube_height, cube400_x, cube400_y, cube_width, cube_height)
' If no collision, update position
if not collision then
cube500_x = new_x
cube500_y = new_y
end if
end sub
Page created in 0.127 seconds with 11 queries.