Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
Pong Game Support Needed!!!
Old
manthan98
Junior Member
 
Status: Offline
Posts: 5
Join Date: Jan 2014
Location: Toronto
Exclamation Pong Game Support Needed!!! - 01-15-2014, 08:34 AM

I made a pong game but i need help with incorporating a timer... anyone want to help... thx
Attached Files
File Type: a2w AlicePongV2.a2w (161.9 KB, 6 views)
   
Reply With Quote
Maybe
Old
MrMoke
Senior Member
 
MrMoke's Avatar
 
Status: Offline
Posts: 500
Join Date: Sep 2007
Location: Austin, Texas
Default Maybe - 01-15-2014, 01:36 PM

Putting the 3D Text2.Time() method in the While event is slowing everything. It needs to run in parallel with all other events.

Also, if you upgrade to 2.4.1, nothing will work
   
Reply With Quote
Reply
Old
manthan98
Junior Member
 
Status: Offline
Posts: 5
Join Date: Jan 2014
Location: Toronto
Exclamation Reply - 01-16-2014, 07:39 AM

Yes i realized that as well... Do u have any idea on how i can incorporate the timer properly so that it runs smooth and doesnt crash...
   
Reply With Quote
Speed UP
Old
chickentree
Super Moderator
 
Status: Offline
Posts: 210
Join Date: Dec 2012
Location: Frosno, Ca
Default Speed UP - 01-16-2014, 08:45 AM

Quote:
Originally Posted by manthan98 View Post
Yes i realized that as well... Do u have any idea on how i can incorporate the timer properly so that it runs smooth and doesnt crash...
I did not have it crash, but did not do any kind of exhaustive testing either.

Two things to make it go faster:
  1. Make another While the world is running event and put the 3D Text2.time method there. (Mr. Moke's Suggestion.)
  2. Where possible, nest your if statements.

By nesting your if statements you only look at the next condition if the first one fails. So rather than:
Code:
if right then 
    do this
else 
    Do Nothing

if left then
   do that
else
    Do Nothing
You have:
Code:
if right then
    do this
else
    if left then
        do that
    else 
        Do Nothing
Note that you can use the pattern above to merge right and left or forward and back or ... but you cannot use it to combine right, left, forward, and back. Can you see why?

While this trick did seem to speed up the movie a good deal, I have no idea why it worked in this case. My confusion lies in the fact that, in this movie, most of the time the answer to the if statements will be false (we are not out of bounds) so all the conditions will be checked anyway and none of them will execute the "then" part.)

Situations like this in I typically group under the acronym MES (Magical Electrical Stuff.) To make it sound like I know what I am talking about


Mark Henwood
mhenwood@ieee.org
   
Reply With Quote
Hi Again
Old
MrMoke
Senior Member
 
MrMoke's Avatar
 
Status: Offline
Posts: 500
Join Date: Sep 2007
Location: Austin, Texas
Default Hi Again - 01-16-2014, 12:05 PM

Sorry for the delay-

Good info from the Chicken

I don't actually recommend the "While World is running" event, as the third part can seemingly never happen.
My preference is to add a "when World Starts" event for a CountDown method.

The CountDown Method:
1) While Loop doing nothing until a given Boolean variable changes from false to true.
2) It Then, Counts down to zero.
3) It Then, Sets the Boolean variable back false.
4) And is finished.

All other methods that need to can also use the Boolean variable for control.
Also note that all of the "when World Starts" events act as though they are all in a Big "Do together", and the single Boolean Variable gives you logical program control.

Last edited by MrMoke; 01-16-2014 at 04:33 PM.
   
Reply With Quote
Thx
Old
manthan98
Junior Member
 
Status: Offline
Posts: 5
Join Date: Jan 2014
Location: Toronto
Default Thx - 01-17-2014, 08:08 AM

Thx for the help and support... Appreciate it
   
Reply With Quote
Old
chickentree
Super Moderator
 
Status: Offline
Posts: 210
Join Date: Dec 2012
Location: Frosno, Ca
Default 01-17-2014, 11:01 AM

Quote:
Originally Posted by MrMoke View Post
Sorry for the delay-

Good info from the Chicken

I don't actually recommend the "While World is running" event, as the third part can seemingly never happen.
My preference is to add a "when World Starts" event for a CountDown method.

The CountDown Method:
1) While Loop doing nothing until a given Boolean variable changes from false to true.
2) It Then, Counts down to zero.
3) It Then, Sets the Boolean variable back false.
4) And is finished.

All other methods that need to can also use the Boolean variable for control.
Also note that all of the "when World Starts" events act as though they are all in a Big "Do together", and the single Boolean Variable gives you logical program control.
Ah, FYI traditionally that's "tree" not "chicken" just to be pandantic and A-retentive
Why didn't I take the blue pill??
Mark


Mark Henwood
mhenwood@ieee.org
   
Reply With Quote
Mr Moke
Old
manthan98
Junior Member
 
Status: Offline
Posts: 5
Join Date: Jan 2014
Location: Toronto
Exclamation Mr Moke - 01-19-2014, 04:05 PM

Mr Moke i tried implementing your suggestion but i still do not really get what you mean... could u plz try being a little more clear
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2017, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.