Alice Community  

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

Reply
 
Thread Tools Display Modes
How do I make a point counter
Old
Valrshandra
Guest
 
Status:
Posts: n/a
Default How do I make a point counter - 02-19-2010, 02:30 PM

I need help I'm making a game but I can't figure out how to count the points?
   
Reply With Quote
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 978
Join Date: Sep 2009
Location: United States
Default 02-19-2010, 03:21 PM

Well it depends when you want the points to be counted.

First of all though, click on "world" in the object list, and then make a world variable (go to variable (next to method) and create variable), make it a number and call it "points".

Then, whenever in your game when you want points to be added, create a code by dropping the variable "points" into the method and click "increment by 1". This way, whenever you do something to score a point, the variable "points" goes up by 1. If you want it to be more than one, you can do ("points" set value to ("points" + 2)). (switch the 2 for the number you want it to go up by)

If you do not understand, just upload your world and tell me where you want the points to be added, and I can just do it for you and then take a picture and put it onto the forums for you to see, and also upload the new world.


Check out my best projects so far and please comment:

Tic-Tac-Toe 2.0 ................... http://www.alice.org/community/showthread.php?t=3548
Alice Paint ........................... http://www.alice.org/community/showthread.php?p=23408
Real-Time Clock .................. http://www.alice.org/community/showthread.php?p=12725
Maze Game ......................... http://www.alice.org/community/showthread.php?t=4301
   
Reply With Quote
Old
zarfang8
Guest
 
Status:
Posts: n/a
Default 02-19-2010, 03:42 PM

You can show the points on the screen by having a 3d text set text to What as a string, and what being the amount of points. put this in an infinite loop.
   
Reply With Quote
Points?
Old
draudia
Guest
 
Status:
Posts: n/a
Default Points? - 03-01-2010, 11:00 AM

Can't seem to find where you are supposed to set the 3D text to the variable points? I have attached a simple example?

Thanks
Attached Files
File Type: a2w Points.a2w (167.7 KB, 56 views)
   
Reply With Quote
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 978
Join Date: Sep 2009
Location: United States
Default 03-01-2010, 02:56 PM

This is how you do it. Basically there is a function under the World tab that says "(What) as a string". You put this into the Set text to from the 3d text and then put in the variable Points for "What".
Attached Files
File Type: a2w Points.a2w (184.9 KB, 107 views)


Check out my best projects so far and please comment:

Tic-Tac-Toe 2.0 ................... http://www.alice.org/community/showthread.php?t=3548
Alice Paint ........................... http://www.alice.org/community/showthread.php?p=23408
Real-Time Clock .................. http://www.alice.org/community/showthread.php?p=12725
Maze Game ......................... http://www.alice.org/community/showthread.php?t=4301
   
Reply With Quote
Old
zonedabone
Senior Member
 
zonedabone's Avatar
 
Status: Offline
Posts: 578
Join Date: Nov 2008
Location: In the interwebs
Default 03-01-2010, 05:28 PM

Also, if you hate that decimal, there is a little known fact that allows alice to output integers. Instead of your variable in the what as sting function, drag in the random function from the world's functions. Set the minimum and maximum as your variable, and set int only to true.
Attached Files
File Type: a2w integer.a2w (167.1 KB, 27 views)


'Apple Macintosh' - An anagram of 'Complaints Heap'

M.A.C.I.N.T.O.S.H. - Machine Always Crashes, If Not, The Operating System Hangs.

You're *such* a mac person.
   
Reply With Quote
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 978
Join Date: Sep 2009
Location: United States
Default 03-01-2010, 05:42 PM

I actually thought of trying that, but I never did. I guess it does work, thanks. Is is possible to just make this into a function, and then whenever you want to display a number, instead of doing the random thing all the time just run the number through a parameter to a function that has the random code? I think that would be easier for multiple uses of this code.


Check out my best projects so far and please comment:

Tic-Tac-Toe 2.0 ................... http://www.alice.org/community/showthread.php?t=3548
Alice Paint ........................... http://www.alice.org/community/showthread.php?p=23408
Real-Time Clock .................. http://www.alice.org/community/showthread.php?p=12725
Maze Game ......................... http://www.alice.org/community/showthread.php?t=4301
   
Reply With Quote
Old
zonedabone
Senior Member
 
zonedabone's Avatar
 
Status: Offline
Posts: 578
Join Date: Nov 2008
Location: In the interwebs
Default 03-01-2010, 05:48 PM

Yep. Here's a function that returns a number as a string, but if the number is an int, it will truncate the decimal! How perfect!
Attached Files
File Type: a2w integer.a2w (174.2 KB, 41 views)


'Apple Macintosh' - An anagram of 'Complaints Heap'

M.A.C.I.N.T.O.S.H. - Machine Always Crashes, If Not, The Operating System Hangs.

You're *such* a mac person.
   
Reply With Quote
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 978
Join Date: Sep 2009
Location: United States
Default 03-01-2010, 05:50 PM

Thanks, now when people ask how to display a variable without decimals I will try to find this post and post the link.

I'm not going to download it only because I know what it looks like, but I hope this helps other people who have this problem. I am going to use this in my future games when I need to display an integer rather than a double variable.


Check out my best projects so far and please comment:

Tic-Tac-Toe 2.0 ................... http://www.alice.org/community/showthread.php?t=3548
Alice Paint ........................... http://www.alice.org/community/showthread.php?p=23408
Real-Time Clock .................. http://www.alice.org/community/showthread.php?p=12725
Maze Game ......................... http://www.alice.org/community/showthread.php?t=4301
   
Reply With Quote
3D Set Text To... Not a method?
Old
draudia
Guest
 
Status:
Posts: n/a
Default 3D Set Text To... Not a method? - 03-02-2010, 09:21 AM

Thanks for posting that. However, in my version of Alice there is no method called "3D Set Text To....". I have looked all over for it and doint see it. Is it a custom method that you made?
   
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.