• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Random class cycling.

 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know I'm going to feel stupid about this, but I can't seem to figure what's going on. This is a fun project so there's no URGENCY whatsoever. Basically, I wrote a little framework for someone here at the ranch for a space applet. I've been playing with it and (not to slap myself on the back) it's really cool how simple it is to add objects to the animation scene and give them all sorts of behavior. Anyway I have an explosion sequence, where a ship breaks apart, what is actually happening in the code is the ship creates four new scene objects and removes itself from the scene. The aft debris section where the engine is located I have firing randomly at a 1/20 probabilty. It works fine at first, but after a while the engine comes on and stays on. Anyway here's the pertinent code:

Thanks in advance.
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Amazing how when you post something you immediately see the problem. The cyclesToBurn variable can be 0 DOH! So on the next update, the if (--cyclesToBurn == 0) fails because cyclesToBurn is -1 so the engine is never shut off.
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Glad we could help, Michael.
...though come to think of it I was kinda wondering what the "cyclesToBurn = 0" was there for, since you just checked to see that it was == 0. But I guess you're revising that part anyway...
This is a fun project so there's no URGENCY whatsoever
Cool. Next time, be sure and put NOT URGENT!!! in the subject line, and we'll probably respond much more promptly.
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
...though come to think of it I was kinda wondering what the "cyclesToBurn = 0" was there for

You know how sometimes when you've exhausted all logic and reason (at least you think you have) and desperation kicks in? Like, what the hell maybe this'll fix the damn thing. That's where the cyclesToBurn = 0 came from. A roll of the dice.
 
Can't .... do .... plaid .... So I did this tiny ad instead:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic