Saturday, June 9, 2018

HP Prime: The Money Machine Game


HP Prime: The Money Machine Game



The month of games continue…

This is a simple game where the machine randomizes between $250 to $50,000.  Press [ Enter ] whenever you feel lucky.  Good luck!

HP Prime Program GAME_MONEY

EXPORT GAME_MONEY()
BEGIN
// Money Machine random game
// 2018-03-26 EWS

// Localize variables
LOCAL K,c,d,s,lst,t1,t2,t3;

// Dark green screen (fir green)
RECT(#003000h);

// Intro screen
K:=GETKEY;
WHILE K≠30 DO
TEXTOUT_P("Are you ready to make money?",
0,0,4,#FFFF00h);
TEXTOUT_P("Then step right up, to the",
0,20,4,#FFFF00h);
TEXTOUT_P("Money Machine! Press ENTER",
0,40,4,#FFFF00h);
TEXTOUT_P("when you feel lucky! GOOD LUCK!",
0,60,4,#FFFF00h);
TEXTOUT_P("Press ENTER to continue.",
0,120,4,#00FFFFh);

K:=GETKEY;
END;

// The game
lst:={250,250,250,500,500,500,
1000,1000,1000,2000,2000,2000,2500,
2500,5000,5000,10000,15000,25000};
S:=SIZE(lst);

K:=GETKEY;
WHILE K≠30 DO
RECT(0);

// decorate
t1:=RANDINT(0,310);
t2:=RANDINT(0,310);
t3:=RANDINT(0,310);
// star is character 9733
TEXTOUT_P(CHAR(9733),t1,0,4,#FFFFFFh);
TEXTOUT_P(CHAR(9733),t2,0,4,#FFFFFFh);
TEXTOUT_P(CHAR(9733),t3,0,4,#FFFFFFh);
TEXTOUT_P(CHAR(9733),t1,200,4,#FFFFFFh);
TEXTOUT_P(CHAR(9733),t2,200,4,#FFFFFFh);
TEXTOUT_P(CHAR(9733),t3,200,4,#FFFFFFh);

// generate dollar amount
c:=RANDINT(1,S);
d:=lst[c];
// 7 is the largest font
TEXTOUT_P("$"+STRING(d),100,60,7,#00FF00h);
// wait one quarter second
WAIT(1/4);
K:=GETKEY;
END;

// Results screen
RECT(#003000h);
TEXTOUT_P("$"+STRING(d),100,60,6,#00FFFFh);
TEXTOUT_P("You won $"+STRING(d)+"!",
0,180,4,#FFFFFFh);
WAIT(0);

END;

Eddie

All original content copyright, © 2011-2018.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.  Please contact the author if you have questions.

  Casio fx-7000G vs Casio fx-CG 50: A Comparison of Generating Statistical Graphs Today’s blog entry is a comparison of how a hist...