Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / cool random message program!

Author
Message
Gamer Making
18
Years of Service
User Offline
Joined: 20th Sep 2006
Location: sitting at the comp programming
Posted: 7th Apr 2007 05:41



Like it? say yes if you do.

Bach Tran
Gamer Making
18
Years of Service
User Offline
Joined: 20th Sep 2006
Location: sitting at the comp programming
Posted: 7th Apr 2007 05:50
lots of beginners should figure out how this works.

Bach Tran
Essence
22
Years of Service
User Offline
Joined: 12th Oct 2002
Location: The Netherlands
Posted: 7th Apr 2007 14:54
why use the 'printat()' function while you can use the 'text' function?

text x,y,string$

Current project: MiRevu Visual Gaming Engine
thread: http://forum.thegamecreators.com/?m=forum_view&t=103073&b=8
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 7th Apr 2007 18:11
Lol, not bad, I started with this kind of stuff when I was a newcomer.

n008
17
Years of Service
User Offline
Joined: 18th Apr 2007
Location: Chernarus
Posted: 21st Apr 2007 03:08
Uhh... WTF!? Ur program doesn't work!!

Ling creckt tsi nocreckto havela? NASA chetallnar mo lu'ul nasding!
Code Dragon
18
Years of Service
User Offline
Joined: 21st Aug 2006
Location: Everywhere
Posted: 24th Apr 2007 20:18 Edited at: 26th Apr 2007 22:37
I don't think newcomers should figure out how it works, I'm not trying to be mean but it looks more like it was written by a newcomer to me.

1 - Colors are between 0 and 255, not 1 and 256
2 - A 640x480 screen has pixels 0-639 and 0-479, not 0-640 and 0-480
3 - You need a randomize timer
4 - printat() should be changed to a text command
5 - You should indent your code
6 - You need to close the quote (probably why n008 posted)

Here's the fixed version



By reading this sentence you have given me brief control of your mind.
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 24th Apr 2007 22:35
Someone's been watching too much Bill & Ted

sadsack
20
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 25th Apr 2007 02:58
I am not going to say anything.
renny
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 25th Apr 2007 04:45 Edited at: 25th Apr 2007 04:54
Quote: "Colors are between 1 and 255"


Actually, using 256 is correct...

Rnd(X) returns a number between 0 and X-1 inclusive. So, Rnd(256) can return 0, 1, 2, and so on up to 255 - but never 256. What he put therefore returns 0-255 which is correct for colours.

Using Rnd(), the same can be said for the 640x480 screen resolution.

However, it still doesn't take anything away from the fact that the snippet is pretty naff and useless...

TDK_Man

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 25th Apr 2007 11:45
Quote: "Colors are between 1 and 255"

technically, 0 and 255 which gives the 256 bit range.


dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 25th Apr 2007 12:08 Edited at: 25th Apr 2007 12:09
Quote: "Rnd(X) returns a number between 0 and X-1 inclusive. So, Rnd(256) can return 0, 1, 2, and so on up to 255 - but never 256. What he put therefore returns 0-255 which is correct for colours."


Using DBP this isn't true, using rnd 255 you will get values from 0 to 255, using 256 you'll get 0 to 256. Try the code below, using your theory it should never quit.




Quote: "
technically, 0 and 255 which gives the 256 bit range."


You mean 8 bit range .

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 25th Apr 2007 21:01
i corrent one mistake and make another one myself, figures!


Code Dragon
18
Years of Service
User Offline
Joined: 21st Aug 2006
Location: Everywhere
Posted: 25th Apr 2007 23:13
Quote: "Quote: Colors are between 1 and 255
technically, 0 and 255 which gives the 256 bit range.
"


I know, just a typo. What is range though, the number of bits required to hold that range of numbers?

By reading this sentence you have given me brief control of your mind.
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 26th Apr 2007 00:34
dark coder

You are correct - sorry, I was mixing up what you do if you want a random number between 1 and X (Rnd(X-1)+1).

Quote: "What is range though, the number of bits required to hold that range of numbers?"


8-bit colour values are stored in a byte (8 binary bits) which can store 256 unique bit patterns (0 to 255) - hence the 256 colour limit.

In higher colour modes (like 24 bit), each of the red, green and blue elements have a byte each - giving you a range of 0 to 255 shades of each colour.

TDK_Man

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 27th Apr 2007 00:41
This might help explain a few things for you.
http://zimnox.com/hexbin/


Code Dragon
18
Years of Service
User Offline
Joined: 21st Aug 2006
Location: Everywhere
Posted: 27th Apr 2007 04:23 Edited at: 27th Apr 2007 04:26
Well, I know how 24-bit color works and how to convert from decimal to binary to hexidecimal to octal, I've just never heard of the term range. I usually say 8 bits would have 2^8 = 256 permutations rather than 256 range.

[edit]

Just found out what range is on wikipedia. Is it really neccessary that DBPro supports ranges of −9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 though?

By reading this sentence you have given me brief control of your mind.
dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 27th Apr 2007 11:31
Quote: "Is it really neccessary that DBPro supports ranges of −9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 though?"


DBP already does, it's called the Double Integer.

Code Dragon
18
Years of Service
User Offline
Joined: 21st Aug 2006
Location: Everywhere
Posted: 28th Apr 2007 03:37
Quote: "DBP already does, it's called the Double Integer."


I know. I was just asking why in the world it supports 64 bit intergers because it seems kind of silly that DBP supports numbers up to 9 million trillion.

By reading this sentence you have given me brief control of your mind.
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 30th Apr 2007 07:27
Probably because DBC needed the ability to use bigger numbers and the types now used in DBP are just the next step up size-wise.

Remember, adding just one more byte for data storage with a variable increases the maximum number storable by an incredible amount.

1 byte = 255 max number
2 bytes = 65535 max number

TDK-Man

Login to post a reply

Server time is: 2024-11-22 18:44:04
Your offset time is: 2024-11-22 18:44:04