LoginLogin

DEFY Code Library

Root / Talk About Programs / [.]

AveryCreated:
http://www.smilebasicsource.com/page?pid=143 So I made this thread to talk about DEFY. I want to bring up something I have been programming, and is almost done, which is TOPOINT(). It is meant to store two 16-bit sign and magnitude integers in a single numerical value for space conservation. That means you can have integers between ±32767 as well as -0 which represents NaN. It will have GETX() and GETY() to extract the numbers, and some additional commands compatible with point type. What do you guys think?

hmm. No one wanted to talk about that. I admit, TOPOINT() isn't that special. But now I'd like to hear your opinions on CPHA2$(), which I just added. Do you guys like that one? If not, what's wrong with it?

Could you give command syntax? You didn't explain how TOPOINT or GETX/Y are used.

P=TOPOINT(X,Y) X=GETX(P) Y=GETY(P)

CAP can be variable=MIN(MAX(variable,Minimum),Maximum) (at least use this in the DEF) LF$() Smilebasic never uses line feed NULL$() should be NUL$ TOUCHP() should return -1 if screen is not touched My suggestions: Q$() (quotation mark) HSVREAD Color OUT h, s, v

CAP can be variable=MIN(MAX(variable,Minimum),Maximum) (at least use this in the DEF)
Oh. I thought MIN and MAX only worked on arrays.
LF$() Smilebasic never uses line feed
I thought it does... it works like a line break.
?"ABC"+LF$()+"XYZ"
ABC
XYZ
Honestly, I would have expected you would go after CR$() which just puts that blue line end character you see in the source code editor.
NULL$() should be NUL$
I was really debating which way would be better. If you say so, I'll change it to NUL$.
TOUCHP() should return -1 if screen is not touched
Another thing I was considering, but here's my reason for it defaulting to 0. I find it nice being able to just put it straight into an IF statement, and have it work as testing if the screen is touched, without having to put "!=-1". And TOUCH OUT can only return X between 5-314 and y 5-234. (I have purposefully miscalibrated my touch screen to check this.) So it will not be confused with being touched in the top left corner in practice.
My suggestions: Q$() (quotation mark)
Putting in a quotation mark constant is a great idea. It just shouldn't be Q$(). It's one letter, and I don't want an error when a programmer gets an error when making their own DEF Q$(). I think it should be QUOT$() or QT$().
HSVREAD Color OUT h, s, v
I honestly didn't take the HSV() function seriously because I just made it out of boredom. But, it is a useful function, actually. It should have an HSVREAD OUT, but that will mean I'll have to take out the automatic dithering it does.

So I have made an incomplete 3D rendering engine I'm hoping to implement into DEFY. Here's a little demo. Public key: 4343X541 It just takes in points and polygons which connect to the points, have colors, and it also takes in the position and rotation of the camera, which you can control while the program runs.

Wow. This is incredibly awesome. But, you could do a constant which contains Phi number? And call it PHI()? Ex.
INPUT "VALUE 1"; V1
V2=V1×PHI()
Because for programs that needs Phi, it is boring to make 12 numbers of the Fibonacci sequence and divide just the two last numbers to obtain Phi.

What should be in the code for it? Should it do some computation or just return a constant to a few digits?

It supposed to do a series of computation for obtaining a (maybe) almost exact representation of Phi

Return a constant. It's faster.

Because Phi is used in computations with the golden ratio and others And I give you an example of what should be the code:
DIM FIB[12]
FOR N=2 TO 12
FIB[N]=FIB[N-1]+FIB[N-2]
Or something more longer and repeating but more safe

Well yeah. Just a constant

I have added HSVREAD and PHI() to DEFY 1.7.8

I made it! partially....