In this and in the next two blog entries will show some of the basics on how to design a simple game.
The first program is called MOVEM. This really isn't a game, but it is to introduce the GETKEY function on the HP Prime. The GETKEY gets the last key pressed, while the programmer decides what happens with each key stroke. Each key will return a key code.
The key codes used are:
50: plus key
Other common key codes include 30 for Enter.
The HP Prime pixel screen is 320 x 240, with row pixels 0-319 going right, and column pixels 0-239 going down.
The size of the text that is used in MOVEM series is size 2, which means that the characters are 10 pixels long by 12 pixels high.
Comments in the program are followed by two forward slashes. They don't have to be typed into the program, but they will provide helpful notes.
To run MOVEM, call up MOVEM and move the "M" around the screen using the arrow keys on the arrow pad. Exit by pressing the Plus (+) button. Note the code after each arrow movement - your character ("M") will not move beyond the screen's borders.
// clear the screen
// set up the character
// Start the main loop
// Move Left
IF K==7 AND A>0 THEN
// Move Right
IF K==8 AND A<320 THEN
// Move Down
IF K==12 AND B<240 THEN
// Move Up
IF K==2 AND B>0 THEN
// Exit using the Plus Key
The next blog entry will show how to put a goal and immovable solid objects.
This blog is property of Edward Shore - 2014.
Review: Canon F-605 Scientific Calculator Company: Canon Type: Scientific Memory: 7 registers Battery: LR54 x 1 Yea...
Casio fx-991EX Classwiz Review Casio FX-991EX The next incarnation of the fx-991 line of Casio calculators is the fx-991 EX. ...
One of the missing features of the TI-82/83/84 family is the ability to convert between bases. Here are two programs in TI-Basic to help...
HP Prime: Basic CAS Commands for Polynomials and Rational Expressions Define the following variables: poly: a polynomial o...