Page 1 of 1

repeat and wait together in move

Posted: Sat Nov 23, 2013 12:25 pm
by chris25
Yes I know, sorry, but really I have tried all sorts of combinations involving the repeat while and repeat statements. Human logical thinking has not helped me solve this so please could you show me the correct syntax
I am simply wanting to slow down the movement from pixel to pixel. If I am not worthy of the answer then just a clue would make me happy. Actually a clue might be better, thanks, I really get annoyed at not being able to work it out. Thankyou.
on moveBox
if keysdown() = 65362 then
set the top of the button "box" to the top of the button "box" - 1
--wait 30 ticks
end if

Re: repeat and wait together in move

Posted: Sat Nov 23, 2013 12:49 pm
by Klaus

Code: Select all

on movebox
  if keysdown() = 65362 then
     set the top of the button "box" to the top of the button "box" - 1
  end if
  --wait 30 ticks

  ## If you want a handler to do the same over a preiod of time, SEND the message again with a delay!
  send "movebox" to me in 30 ticks
end movebox
8)

Re: repeat and wait together in move

Posted: Sat Nov 23, 2013 1:06 pm
by jmburnod
Hi Chris,

You can use a local time counter to do that

Code: Select all

local sChrono
on moveBox
   if keysdown() = 65362 then
      if the ticks > (sChrono + 30) then
         set the top of the button "box" to the top of the button "box" - 1
         put the ticks into sChrono
      end if
   end if
end moveBox
Jean-Marc

Re: repeat and wait together in move

Posted: Sat Nov 23, 2013 1:21 pm
by chris25
When I see the answer it's seems so obvious. Thankyou. Jean - Marc thanks for the variation.

Re: repeat and wait together in move

Posted: Sat Nov 23, 2013 5:34 pm
by dunbarx
Chris.

It isn't so much that you miss the obvious, it is rather that you have undertaken all of LC at once, and do not have the experience with techniques and tricks (and work-arounds) that have been learned over many years. Decades in some cases. Your progress is lightning-like. Your dedication and stubbornness are inspirational. We are patient. So must you be.

Craig

Re: repeat and wait together in move

Posted: Sat Nov 23, 2013 6:08 pm
by chris25
That is a good point and I do agree with you. I definitely tried to keep it simple though. Which is why I came up with this - All I am doing is the following:

To learn different movement techniques:
To grind myself in the use of variables and Functions:
To grasp randomization:
To learn how to use intersection with objects whereby the area of impact varies at a different radius from the centre:

I am learning much more besides and feel that despite the apparent ignorance I have shown in my questioning each answer is providing so much more than just an answer to the current problem. I am building up a library of answers and codes that I use to investigate further in other simple tasks, trying to remember to use the message box, practising understanding the debug and watching what happens at breakpoints. Yes it is probably a lot too much too early, and strategy is not something I will not learn in a few months, and I see that it is an inability of being able to conceptualize a sort of mental strategic organization of syntax and methods that causes most of my problems. Anyway I came up with what I thought was simple enough to begin with.

The non-functional graphic stack is here if you are interested.

EDIT, ok try again:

Re: repeat and wait together in move

Posted: Sat Nov 23, 2013 8:25 pm
by jacque
Here's an article I wrote to explain what a function is. It's specifically aimed at new programmers:

http://www.hyperactivesw.com/resources_function.html

Re: repeat and wait together in move

Posted: Sun Nov 24, 2013 12:18 am
by chris25
Jacque very kind of you to post this. I actually have this next to all my references, I read it through a number of times but found it hard to relate to, and putting it into practise after reading was troublesome. However, now that I have experienced a number of situations with functions within a working environment so to speak I can ead your article with a better understanding, it makes more sense to me what you explain.
Kindest regards
chris

Re: repeat and wait together in move

Posted: Sun Nov 24, 2013 5:52 am
by jacque
If it's any consolation, I had a hard time with functions when I first started. And I wrote the article when another new programmer had the same trouble. Once the shoe drops it's easy, but there's no real world parallel for it, it's strictly a programming thing.

You can think of a function like a carrier pigeon. You want some info so you tie a basket to the bird and let it fly off. It comes back with the data in the basket. You put the data into a variable and use it however you want.

Re: repeat and wait together in move

Posted: Sun Nov 24, 2013 7:35 am
by Simon
Jacque WOW!!!
http://www.hyperactivesw.com/Resources.html
HyperCard Tips and Tricks
Both you and Craig Newman have postings in '98!
Your 10 thousand hours are well up.

Chris, do you get it? These guys way way way out of my league.

Simon

Re: repeat and wait together in move

Posted: Sun Nov 24, 2013 7:47 am
by jacque
LOL. I'd been at it over 10 years by then too. I started learning the language with HyperCard 1.0 in 1987. I've known Craig almost all that time too -- only we've never met in person and I still don't know what he looks like.

Re: repeat and wait together in move

Posted: Sun Nov 24, 2013 9:18 am
by chris25
Haven't you two heard of Skype? the humble photograph? no variables needed here.... :)

""Chris, do you get it? These guys way way way out of my league."" Back in the days when I was building the pyramids, I remember having to actually walk some distance to a phone attached to a long piece of string, and then I had to reach down after months of body building, and haul that phone to my ears. After sitting down, due to the exhaustion of having to hold the phone with one hand and then having to turn a great big metal wheely thing with numbers underneath it, I would hear a nice attractive woman on the other end say -"How would you like to be connected sir"....after 5 whole cumbersome minutes and having to leave two rooms, walk 6 metres and sometimes downstairs or upstairs, and grab one chair and close one other door, nobody was in....I like the pyramids

Re: repeat and wait together in move

Posted: Sun Nov 24, 2013 4:36 pm
by dunbarx
Jacque.

Funny. I have had your picture for many years, and had actually noticed that you might not have mine. Guys don't generally notice anything at all, so I am proud of that.

I am computer challenged. My kids, or at least the ones I know about, run my facebook page. I guess you could search for me. I hate being photographed, as you will see...

Craig

Re: repeat and wait together in move

Posted: Sun Nov 24, 2013 6:32 pm
by chris25
While we were on the subject,Jacque, about this article, I noticed that a person called Geoff Canyon had a website link with your article. The website no longer exists, any chance you might know about his article though?

Chris

Re: repeat and wait together in move

Posted: Sun Nov 24, 2013 8:58 pm
by jacque
Oh dear, he's had that site forever. It does seem to be gone now and I can't find where it went. I'll remove the dead link from my article, thanks for the heads-up.