Post Reply 
The Money Machine Game
06-09-2018, 03:02 PM
Post: #1
The Money Machine Game
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
Code:

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;
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)