Converting real to nearest whole no. int

Non-platform specific questions.

Converting real to nearest whole no. int

Postby poopbrigade » Tue Sep 08, 2009 1:58 pm

(>,<)...hello again.


Um, how do you convert a real number to nearest whole number in GE like,
1234.567___to____1235.000
Ive got an idea but I think there's an easier way though.


:mrgreen: thanx in advance :mrgreen:
When life gives you oranges, make orange juice. When life gives you poop, make fertilizer not poop juice.

Image
Current project __ CorPsEdEaRtH
Estimated work done __ 12%
User avatar
poopbrigade
 
Posts: 129
Joined: Thu Aug 27, 2009 12:17 pm
Location: In Earth. Being Burried XD
Score: 46 Give a positive score

Re: Converting real to nearest whole no. int

Postby pyrometal » Tue Sep 08, 2009 2:48 pm

ceil(); rounds up
floor(); rounds down
round(); rounds to nearest int
SPRITE WARRIOR:
Free, open-source & crossplatform pixel art editor (currently under construction).
User avatar
pyrometal
 
Posts: 706
Joined: Wed Nov 28, 2007 4:07 am
Location: Kingston, ON, Canada
Score: 86 Give a positive score

Re: Converting real to nearest whole no. int

Postby poopbrigade » Wed Sep 09, 2009 10:58 am

hey do you also know how to re size an actor in GE.?
When life gives you oranges, make orange juice. When life gives you poop, make fertilizer not poop juice.

Image
Current project __ CorPsEdEaRtH
Estimated work done __ 12%
User avatar
poopbrigade
 
Posts: 129
Joined: Thu Aug 27, 2009 12:17 pm
Location: In Earth. Being Burried XD
Score: 46 Give a positive score

Re: Converting real to nearest whole no. int

Postby Rux » Wed Sep 09, 2009 9:38 pm

There is a way, but it is kind of tricky. It involves a canvas actor. On the draw actor canvas,
Code: Select all
draw_from("player", 0, 1, 1.0);

This will draw your actor which is "player" and place it at 0 x 1 y on the canvas and rezise it by 1.0.
You need to have a regular size version of the actor to use too. This code is good for static animations, but for animated ones, you need to use the erase function. (IDK how to use that)
I'm not good at coming up with signatures...
User avatar
Rux
 
Posts: 645
Joined: Sun Apr 29, 2007 9:26 pm
Location: Sitting on your moniter invisable.
Score: 35 Give a positive score

Re: Converting real to nearest whole no. int

Postby poopbrigade » Thu Sep 10, 2009 12:02 am

thanx anyways, (>,<) I'm not that familiar of some of the functions yet but I'll try my best in understanding it.(>,<)
When life gives you oranges, make orange juice. When life gives you poop, make fertilizer not poop juice.

Image
Current project __ CorPsEdEaRtH
Estimated work done __ 12%
User avatar
poopbrigade
 
Posts: 129
Joined: Thu Aug 27, 2009 12:17 pm
Location: In Earth. Being Burried XD
Score: 46 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron