November 22, 2024, 09:45:24 PM

News:

You can now use Vixen to program your Prop-1 and Prop-2 controllers!  Get started quickly and easily, without having to learn PBASIC.  Details in the Library forum.


Looking to do an elevator effect

Started by Patrick, April 16, 2009, 01:40:51 PM

Previous topic - Next topic

Patrick

My beta testers (teenagers) felt the effect needed one more thing, so I added a new subroutine between Going_Down and Frenetic called Down_Fast.  Essentially, all that does is turns on all of the floor indicators and runs the side lights increasingly faster to give the appearance the elevator is still going down beyond the sub basement.  I added one new Word variable, delay, and added this subroutine:

' -------------------------------------------------------------------------

Down_Fast:
  delay = 1000                           ' set initial one second delay
  OUTH = %00111111                       ' turn all all floor indicators
  DO WHILE delay <> 0                    ' start side light loop
      FOR flIncr = 0 TO 2                ' top to bottom side light seq
        READ (Side + flIncr), SideLight
        PAUSE delay                      ' pause decreases each iteration
      NEXT
    delay = delay - 100                  ' reduce delay by .1 second
  LOOP
  RETURN


I reused the flIncr variable from the first subroutine, not sure if that is bad programming practice, but it appears to work OK.  The code is now "Gold" but I would very much appreciate any tips, comments and criticisms as they will help me learn and grow.  Now that I know what I can do, I have a lot more Prop1/2 ideas!

Patrick

JonnyMac

As llong as flIncr wasn't being used when you call Down_Fast you'll have no troubles.  Keep in mind that the Stamp Editor has a memory map which will show you how memory is laid out; this will let you know if you have variables to spare to prevent possible re-use conflicts.
Jon McPhalen
EFX-TEK Hollywood Office

Patrick

Jon,

If you have a chance, can you take a look at my code on page 1 of this post?  I will be working quite a bit more with my prop controllers and I want to nip any bad programming habits in the bud now.  Already working on my next project, a model rocket launcher for our Boy Scout troop!

Thanks,

Patrick

JonnyMac

I don't see anything terribly egregious, and with HAuNTcon in two days I may not be able to update to JonnyMac style until after.  Things to note:

* Use PIN instead of VAR for single IO points
* Your program just ends; how do you reset it without reseting the whole controller?
* Use Bytes instead of Nibs unless you're running short on variables -- Nibs are synthesized and are less efficient

One I think I fully understand what you want I'll write a version in my style.  Question: What is the relationship between the floor indicators and the IO points?
Jon McPhalen
EFX-TEK Hollywood Office

Patrick

Thanks for the tips, much appreciated.  The trip "down" on the elevator is a one shot which is why I ended it.  Once the group gets off, they will take a tour of the haunt which is actually my office - trying to win a contest here.  I have decided to reverse the trip to take them back up, I would just add another switch to a different door (the "elevator" has three doors) on PIN15 and run the program "backwards".

As for the floor indicators, I have a panel that looks like elevator buttons (horizontal), it has 6 bright LED's behind plastic lenses with the floors stenciled on them.  They are connected  as follows:

Floor 3 - pin 8
Floor 2 - pin 9
Floor 1 - pin 10
Lobby - Pin 11
Basement - Pin 12
Sub Basement - Pin 13

I can absolutely wait until after Hauntcon.  The program works, but I know it can be better.  I really am looking at improving as I learn how to program (this is my first) and I want to get rid of bad habits early on.

Thanks again,

Patrick

Patrick

Jon,

Love to see your take on this when you get a chance!  Still learning....

Thanks,

Patrick

JonnyMac

A little busy this week, but thanks for the reminder.  While at HAuNTcon I visited a haunt with an elevator sim and it caused me to think of what you were doing.

Will jump on your program after I get a couple big items off my desk.
Jon McPhalen
EFX-TEK Hollywood Office