So, I got an HP Prime today, and I'm going to use this thread as a dumping ground as I do stuff. I made a simple program today. Here's a screenshot:
Code: EXPORT Rects()
BEGIN
Rect();
Local X1,X2,Y1,Y2;
Local Color;
Local ColorR,ColorG,ColorB;
Repeat
X1:=RandInt(0,320);
X2:=RandInt(0,320);
Y1:=RandInt(0,240);
Y2:=RandInt(0,240);
ColorR:=RandInt(255);
ColorG:=RandInt(255);
ColorB:=RandInt(255);
Color:=RGB(ColorR,ColorG,ColorB);
Rect_P(X1,X2,Y1,Y2,Color);
For K From 1 to 100000 Do
End;
Until GetKey≠−1;
END;
Game of Life, here I come!
Wow, now I have a reason to charge my Prime back up
![Very Happy](images/smiles/icon_biggrin.gif)
Will be nice to have someone to bug with questions that might actually understand this language, as few others seem to know about it.
I wouldn't say I really understand it, but I can draw rectangles, so that's basically all I need
I see a delay loop in there, is that needed for anything? How much faster does it run without it?
You and Jonimus having HP Primes makes me want one as well :\ Although for OS disassembly work most likely.
The simulator runs quite a bit faster than the hardware, but the hardware is still quite fast. Without the loop in there it's just a crazy mess of rectangles.
http://www.omnimaga.org/hp-prime/tetris-for-the-hp-prime!/?topicseen
I was thinking about looking at some of this code, to see if I could potentially learn something of the language. I think there might be a few other programs there that might help with that, as well
Just a small update, I can draw a grid and move a cursor around:
Good first steps for Game of Life.
There is actually a GoL already on MoHPC, but it would be nice to see what you can come up with yourself. Glad you got an HP Prime by the way!
Yeah, I saw that in the archives, but it's always my go to learning program, so I figured I'd go ahead and give it a shot.
*Bump* Some more progress tonight:
Question to those who may know: Is there a function call to make the buttons? Right now I'm doing it manually with an Icon, Blit_P and TextOut_P.
*Bump* An answer to my question: DrawMenu();
I've been playing with the input stuff today, to try to get screen presses. Previously I was using GetKey, but that just returns a KeyCode. Looking around at documentation and other people's code, and Wait() seemed to be the correct thing. Some places said it returned a number for keyboard and a list for mouse. This is wrong. It always returns a list. Here's where things get even crazier:
- If it's a keyboard event, it returns the keycode as the only input, for example {30} for enter
- For most key events, it returns a list of the form { type, [x, y], [dx, dy] }
These are the types:
0: Mouse Down
1: Mouse Move
2: Mouse Up (x/y is not provided)
3: Mouse Click (note, if a click is detected, there is no MouseUp)
5: Mouse Stretch. x/y is the delta since the last event. dx/dy is the delta since the ORIGINAL mouse
down...
6: Mouse Rotate, x is original angle, y is new angle in 32nd of a circle.
7: Mouse Long Click, This means that the mouse stayed down for 1 second
NOTE THE MOUSE UP! It returns JUST the type. So JUST {2}. This is the SAME VALUE as is returned when the up arrow is pressed. So if the screen is touched and then you get a {2}, there seems to be no way to tell if it's a mouse up or the up arrow... Possibly you could use GetKey to see if the key was pressed. There's also a Mouse() command I've yet to experiment with.
Of course, the other thing to think about is how likely is it that you're going to get a {2} so soon after a mouse down and it not by a mouse up. This is a valid consideration, but it's still something that could happen, and so I don't like it.
I reproduced your first rectangle program on the calculator, reduced the delay to 100. Trippy.
![Very Happy](images/smiles/icon_biggrin.gif)
Thanks for the code, going to play with it more when I'm done working
For getting screen presses unambiguously there is also the mouse() command which works pretty similar to the Getkey which you described.
Okay, cool. I mentioned in my post that I'd be experimenting with that command next. Good to have some confirmation that it way be a good way to go. THanks
I know I'm a bit late to this party, but I just wanted to say I'm glad to see another HP Prime developer! I hope you continue to do stuff with the system.
Concerning WAIT's syntax: WAIT(0) and WAIT(-1) do different things, and return different things as well. I suggest you check it out.