Hi,
on https://rosettacode.org/ there are many examples to fill: https://rosettacode.org/wiki/Reports:Ta ... n_LiveCode
For the 15 puzzle game I wrote the following code, what do you think? It is appropriate or guide new user to a wrong interpretation of what is livecode?
########CODE#######
#Please note that all this code can be performed in livecode with just few mouse clicks
#This is just a pure script exampe
on OpenStack
show me #Usually not necessary
#tile creation
repeat with i=1 to 16
create button
set the label of button i to i
if i =1 then
set the top of button 1 to 0
set the left of button 1 to 0
end if
if i > 1 and 1 <=4 then
set the left of button i to the right of button (i-1)
set the top of button i to the top of button 1
end if
if i >= 5 and i <= 8 then
set the top of button i to the bottom of button 1
if i = 5 then
set the left of button i to the left of button 1
else
set the left of button i to the right of button (i - 1)
end if
end if
if i >= 9 and i <= 12 then
set the top of button i to the bottom of button 5
if i = 9 then
set the left of button i to the left of button 1
else
set the left of button i to the right of button (i - 1)
end if
end if
if i >= 13 and i <= 16 then
set the top of button i to the bottom of button 9
if i = 13 then
set the left of button i to the left of button 1
else
set the left of button i to the right of button (i - 1)
end if
end if
#this is usally the script directly wirtten in the objects, it's really weird this way
put "on MouseUp" &CR& "if checkDistance(the label of me) then" & CR &"put the loc of me into temp" into ts
put CR& "set the loc of me to the loc of button 16" after ts
put CR& "set the loc of button 16 to temp" & Cr & "end if " & "End MouseUp" after ts
set the script of button i to ts
end repeat
#graphic adjustements
set the visible of button 16 to false
set the width of this stack to the right of button 16
set the height of this stack to the bottom of button 16
end openStack
function checkDistance i
if (((the top of button i - the bottom of button 16) = 0 OR (the top of button 16 - the bottom of button i) = 0) AND the left of button i = the left of button 16) OR (((the left of button i - the right of button 16) = 0 OR (the right of button i - the left of button 16) = 0) AND the top of button i = the top of button 16) then
return true
else
return false
end if
end checkDistance
#####END OF CODE#####
Rosettacode
Want to talk about something that isn't covered by another category?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Rosettacode
Post by MaxV » Thu Jan 05, 2017 12:42 pm
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w
Jump to
- LiveCode Community
- ↳ Announcements
- ↳ Developer Services Marketplace
- ↳ User Groups and Events
- ↳ SoCal LiveCode Group
- ↳ Greater Toronto Area LiveCode Users Group
- ↳ Off-Topic
- ↳ Made With LiveCode
- Getting Started With LiveCode
- ↳ Getting Started with LiveCode - Complete Beginners
- ↳ Getting Started with LiveCode - Experienced Developers
- ↳ Converting to LiveCode
- ↳ App Building Course
- ↳ Simple Messages
- ↳ Calculator
- ↳ Notes
- ↳ Clock
- ↳ Web Browser
- ↳ Weather
- ↳ Compass
- ↳ Photos
- Developing With LiveCode
- ↳ Talking LiveCode
- ↳ Databases
- ↳ Games
- ↳ Internet
- ↳ Multimedia
- ↳ Software Engineering
- ↳ Version Control
- ↳ Feature Proposals
- ↳ Bug Triage
- ↳ Legacy Project: MetaCard
- Extending LiveCode
- ↳ Using Plugins for Customizing the LiveCode IDE
- ↳ Using Externals
- ↳ Making IDE Plugins
- ↳ Building Externals
- ↳ LiveCode Builder
- Platform Specific
- ↳ Windows
- ↳ Mac OS
- ↳ Linux
- ↳ iOS Deployment
- ↳ Android Deployment
- ↳ CGIs and the Server
- ↳ HTML5
- ↳ Raspberry Pi
- Academic Endeavors
- ↳ Teaching with LiveCode
- ↳ Research and Post Secondary
- ↳ LiveCode University
- ↳ Educational Outreach
- Livecode Open Source Archived Forum- closed to posting
- ↳ Engine Contributors
- ↳ IDE Contributors
- ↳ Documentation and Tutorials
- ↳ Brainstorms
- ↳ Community Projects
- ↳ rIDE
- Third Party Extension Support
- ↳ Marketing Your Products
- ↳ Animation Engine
- ↳ chartsEngine
- ↳ MobGUI
- ↳ lcTaskList
- ↳ SQL Yoga
- ↳ MergEXT
- ↳ Data Grid Helper
- ↳ idea2app and Coding School
- ↳ Admin Archive
- LiveCode Hosting
- Forum Archives
- ↳ Archived: Third Party Extension Support
- ↳ rTree
- ↳ rGrid
- ↳ Data Tree
- ↳ Archived: LiveCode Open Source
- ↳ LiveCode Global Jam
- ↳ Testing Support
- ↳ Archived: Academic Endeavors
- ↳ September Academy
- ↳ Summer School 2013
- ↳ Archived: Project Specific
- ↳ Business and Kiosks
- ↳ Digital Art and Portfolios