Sunday, June 3, 2018

HP Prime: At the Races


HP Prime:  At the Races

I am planning to do lots of gaming this month of June 2018.

Note: Symbols that are produced by Unicode should, but may not show up on all browsers. Please make sure your browsers are updated to the latest version.  

🐎 (Trumpet Sounds)  🐎

The program GAME_RACE simulates a race between seven racers:

Apple Ρ½  (Decimal Unicode: 1149, Hexadecimal Unicode: 47D)
Knight (Decimal Unicode: 9822, Hexadecimal Unicode: 265E)
Spade ♠ (Decimal Unicode: 9824, Hexadecimal Unicode: 2660)
Club ♣ (Decimal Unicode: 9827, Hexadecimal Unicode: 2663)
Heart ♥ (Decimal Unicode: 9289, Hexadecimal Unicode: 2665)
Diamond ♦ (Decimal Unicode: 9830, Hexadecimal Unicode: 2666)
Spike (Decimal Unicode: 10021, Hexadecimal Unicode: 2725)

To watch a race in action, all you have to do is to run GAME_RACE.  Betting not included. 



🐎  HP Prime Program GAME_RACE 🐎

EXPORT GAME_RACE()
BEGIN
// 2018-04-15 EWS

// initialize racers
// apple
LOCAL l1:={1149,#FF0000h,300,30};
// knight
LOCAL l2:={9822,#C0C0C0h,300,45};
// spade
LOCAL l3:={9824,#400080h,300,60};
// club
LOCAL l4:={9827,#000080h,300,75};
// heart
LOCAL l5:={9829,#FF0000h,300,90};
// diamond
LOCAL l6:={9830,#F0E090h,300,105};
// spike
LOCAL l7:={10021,#808080h,300,120};

// the race
LOCAL h,k,j,q;

FOR h FROM 1 TO 3 DO
RECT(#00FF00h);
TEXTOUT_P(CHAR(1149)+CHAR(9822)+
CHAR(9824)+CHAR(9827)+CHAR(9829)+
CHAR(9830)+CHAR(10021),125,100,5);
TEXTOUT_P(STRING(3-h+1),125,120,5);
WAIT(1);
END;
TEXTOUT_P(" ",125,120,5,0,25,#00FF00h);
TEXTOUT_P("And they're off!",125,
120,5);
WAIT(0.5);

REPEAT

// background
RECT();

// background
FILLPOLY_P({(20,0),(20,150),
(330,150),(330,0)},#00FF00h);
FILLPOLY_P({(0,0),(0,150),
(20,150),(20,0)},#E0E0E0h);
LINE_P(0,25,330,25);
// crowd
FOR h FROM 20 TO 300 STEP 10 DO
TEXTOUT_P(CHAR(9823),h,0,5);
END;
TEXTOUT_P(CHAR(9818),140,0,5,#000080h);
TEXTOUT_P(CHAR(9819),150,0,5,#FF0000h);
// racers
FOR h FROM 1 TO 7 DO
TEXTOUT_P(CHAR(1149),l1(3),l1(4),5,l1(2));
TEXTOUT_P(CHAR(9822),l2(3),l2(4),5,l2(2));
TEXTOUT_P(CHAR(9824),l3(3),l3(4),5,l3(2));
TEXTOUT_P(CHAR(9827),l4(3),l4(4),5,l4(2));
TEXTOUT_P(CHAR(9829),l5(3),l5(4),5,l5(2));
TEXTOUT_P(CHAR(9830),l6(3),l6(4),5,l6(2));
TEXTOUT_P(CHAR(10021),l7(3),l7(4),5,l7(2));
END;

WAIT(0.5);
// move the racers
l1(3):=l1(3)-RANDINT(1,3)*5;
l2(3):=l2(3)-RANDINT(1,3)*5;
l3(3):=l3(3)-RANDINT(1,3)*5;
l4(3):=l4(3)-RANDINT(1,3)*5;
l5(3):=l5(3)-RANDINT(1,3)*5;
l6(3):=l6(3)-RANDINT(1,3)*5;
l7(3):=l7(3)-RANDINT(1,3)*5;


q:={l1(3),l2(3),l3(3),
l4(3),l5(3),l6(3),l7(3)};
q:=q<5;
q:=Ξ£LIST(q);
UNTIL q>0;

TEXTOUT_P("The race is over!",
0,160,5,#008000h);

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.

TI 84 Plus CE: Consolidated Debts

TI 84 Plus CE: Consolidated Debts   Disclaimer: This blog is for informational and academic purposes only. Financial decisions are your ...