Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sun Aug 18, 2019 8:16 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Fun game to play
PostPosted: Sun Jan 24, 2010 12:24 pm 
Offline

Joined: Sun Nov 23, 2008 12:27 am
Posts: 404
I remember writing this program a few years ago when I was trying to learn Dolphin smalltalk. Basically, its an application with 1 button. When you try to click on the button, the button moves.

The other day I wrote it in Realbasic for my nephew to play. It kept him entertained for 30 minutes :)

Class App
Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = "" End Class
Class Window1
Inherits Window

Window1.MouseMove:
Sub MouseMove(X As Integer, Y As Integer)
if MouseX > (clickMeButton.left) then
clickMeButton.left = clickMeButton.left - 4
end if
if MouseX < (clickMeButton.left +clickMeButton.width) then
clickMeButton.left = clickMeButton.left + 4
end if
if MouseY > (clickMeButton.top) then
clickMeButton.top = clickMeButton.top - 4
end if
if MouseY < (clickMeButton.top + clickMeButton.height) then
clickMeButton.top = clickMeButton.top + 4
end if

// If button goes off screen, reset button to middle.
if clickMeButton.left < 5 or clickMeButton.left > (window1.Width - clickMeButton.Width - 5) then
clickMeButton.left = (window1.Width / 2)
end if
if clickMeButton.top < 5 or clickMeButton.top > (window1.Height - clickMeButton.height - 5) then
clickMeButton.top = (window1.height / 2)
end if
End Sub

Window1 Control clickMeButton:
Sub Action() MsgBox "You Got Me!"
End Sub End Class


enjoy :)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group