I'm making a dice game

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
kim yongsun
Posts: 10
Joined: Sun Apr 26, 2015 7:14 pm

I'm making a dice game

Post by kim yongsun » Thu Mar 30, 2023 11:13 am

I'm making a dice game
It's a game in which two teams, A and B, move forward on the horse's board according to the dice score. And the dice are directly thrown by hand, and the horses are controlled on the monitor of a mobile screen, and the horses is controlled by the score by throwing the dice out of the monitor of a mobile, and if it's 3 points, then the user tab 3 times on the horse then the horse moves to 3 points ahead on the board, and if it's 5 points, then the user tab on the horse then the horse moves to 5 points ahead,
But I'm asking for help because it's hard to write a script for this, 1 time tap(click) is easy but 2~5 times tap(click) is hard script to me,
I know there is a pull-down menu once you click on a horse, so you can move the horse forward depending on the selection of pulldown menu from 1 point to 5 point. but I heard that the pull-down menu is not supported on the mobile, because it is produced as an Android mobile game, but I want one of the two ways anyway Is there anyone who can help me? thanks
Last edited by kim yongsun on Thu Mar 30, 2023 3:46 pm, edited 3 times in total.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9385
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: I'm making a dice game

Post by richmond62 » Thu Mar 30, 2023 12:07 pm

Without a picture of what you want to make it is very difficult to understand.
-
HR.jpg

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9662
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: I'm making a dice game

Post by dunbarx » Thu Mar 30, 2023 3:48 pm

Hi.

Do I understand that you want to be able for your app to detect the number of times the user clicks, and to then do something with that information? If so, that is very hard to do even in the IDE on desktop. There is a method that I used 30 years ago:

Code: Select all

on mouseUp
 wait 20
  if the mouseClick then answer "Two Clicks"
  else answer "One Click"
end mouseUp
But this is hard to implement beyond two clicks, and I think on mobile it is impossible.

But what to you mean by "tab on a horse"? I assume you mean "click" on a horse. But then what is the problem? The user throws a three, and then clicks on a horse three times. Each time the horse moves a certain distance. What am I missing?

Craig

kim yongsun
Posts: 10
Joined: Sun Apr 26, 2015 7:14 pm

Re: I'm making a dice game

Post by kim yongsun » Thu Mar 30, 2023 5:01 pm

thank you for your answer!

is it hard?
i want a horse that advances by the number of times I click, that is, a horse that goes to a place corresponding to that value if I click 5 times.

this is a script made by chatGPT
but did not work.

on mouseUp
put movePiece(my currentPosition, the number of clicks of me) into my currentPosition
set the location of me to point my currentPosition of the points of my team
end mouseUp

on movePiece pPiece, pClicks
repeat pClicks times
add 1 to pPiece
if pPiece > 5 then
set pPiece to 1
end if
end repeat
return pPiece
end movePiece

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9662
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: I'm making a dice game

Post by dunbarx » Thu Mar 30, 2023 6:31 pm

Kim.

First off, please put all scripts into their tags "</>".

Second, I would learn LiveCode before I started trying to let ChatGPT do my work. That said, how much LC do you know? I cannot help you without that information.

Craig

kim yongsun
Posts: 10
Joined: Sun Apr 26, 2015 7:14 pm

Re: I'm making a dice game

Post by kim yongsun » Thu Mar 30, 2023 7:43 pm

hi
I know liveCode a little
I used hyperCard long ago and knew liveCode based hypercard,
At that time, I wanted to learn livecode and to make a app.
but it is hard to me, I speak english not well
now I am learning liveCode from chatGPT,
chatGPT was knowing liveCode well,
We talk in Korean about liveCode coding,
But I couldn't solve the same problem as now, so I'm asking here
in my poor English skills. I developed an English word learning application with live code a few years ago and gave up in the last process. The word reading function didn't work on Android text to speech The function was not supported by liveCode. I gave up then and bought a license again these days to develop and learn a dice game, but it's not easy.

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: I'm making a dice game

Post by Klaus » Thu Mar 30, 2023 8:27 pm

안녕하세요 김 :-)
(Thanks to Google)

포럼에 오신 것을 환영합니다
welcome to the forum!

I noticed a little error in your script:

Code: Select all

on movePiece pPiece, pClicks
   repeat pClicks times
      add 1 to pPiece
      if pPiece > 5 then
         ## set pPiece to 1
         ## This is not BASIC! :-D

         ## This will do in LC:
         put 1 into pPiece
      end if
   end repeat
   return pPiece
end movePiece
Best

Klaus

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7235
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: I'm making a dice game

Post by jacque » Thu Mar 30, 2023 9:56 pm

당신의 결단력에 감탄합니다.
I admire your determination.

ChatGPT is not skilled in LiveCode coding, it is better to learn it here. You said the dice was thrown by the user, outside the app. If so, then the user knows the number of moves and only needs to click the horse the same number of times. (This is what Dunbar said.) So if the dice say 5, then the user clicks 5 times. Your mouseUp handler moves the horse each time.

If you want the computer to calculate the dice, it must create a random number from 2 to 12 and then use that number to move the horse. This example is for 2 six-sided dice:

Code: Select all

on mouseUp
  put random(11)+1 into tMoves -- for one dice, use random(6)
  repeat tMoves times
    moveHorse -- rename the mouseUp handler you already wrote
  end repeat
end mouseUp
The moveHorse handler is the one you already wrote, it moves the horse 1 square. Or you can replace "moveHorse" with the same commands inside this handler.

도움이 더 필요하시면 저희에게 알려주십시오.
If you need more help, let us know.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9662
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: I'm making a dice game

Post by dunbarx » Thu Mar 30, 2023 10:35 pm

Kim.

Me too.

Play with this stack. It has scripts in the two buttons and on the horse image. Please examine these. I tried to make the stack easy to understand.

This is how you start, with a simple foundation, and then build on that.

Craig
Horses.livecode.zip
(131.92 KiB) Downloaded 47 times

kim yongsun
Posts: 10
Joined: Sun Apr 26, 2015 7:14 pm

Re: I'm making a dice game

Post by kim yongsun » Fri Mar 31, 2023 2:32 am

Thanks to all of you!! I will do as you told me. thanks ~

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9385
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: I'm making a dice game

Post by richmond62 » Fri Mar 31, 2023 8:30 am

I don't think you need artificial intelligence for this bit:
-
SShot 2023-03-31 at 10.29.14.png
-
Attachments
Chuck-A-Luck.livecode.zip
Stack.
(50.04 KiB) Downloaded 43 times

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9385
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: I'm making a dice game

Post by richmond62 » Fri Mar 31, 2023 1:55 pm

Well, this took me 15 minutes, and about half of that time was spent messing around with the images.
-
race day.jpg
-
Now, with a bit of thinking it should be extremely easy to combine those 2 stacks. :D
Attachments
Epsom Downs.livecode.zip
Stack.
(31.3 KiB) Downloaded 48 times

kim yongsun
Posts: 10
Joined: Sun Apr 26, 2015 7:14 pm

Re: I'm making a dice game

Post by kim yongsun » Sun Apr 02, 2023 12:23 pm

thanks lot ~

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”