The fourth part of this miniseries will introduce MOVEM6. In this edition, we will put a condition that is required to be met: collect ten dollar signs ($), called coins in this game, in order to unlock a barrier at the top of the screen. Once the barrier is unlocked, the player can get to the goal.
The bottom of the screen will show the number of dollar signs left to collect.
Once again, you are controlling the π character. Press the plus key to quickly exit the game.
Program:
EXPORT MOVEM6()
BEGIN
// Version 6
// 20140216
// Collect 10 coins to unlock the goal
// A status screen is added on the bottom
// Bottom row is not avialable for play
// Game introduction
MSGBOX("Collect all 10 coins to unlock
the goal!");
// Clear the screen
RECT();
// Cursor set up
LOCAL A,B,C,D;
A:=150;
B:=216;
C:=150;
D:=216;
TEXTOUT_P("π",A,B,2);
// Draw Coins
LOCAL costr,L2,L3,cx,cy,I,coins;
coins:=10; // counter
L2:=RANDINT(10,0,31)*10;
L3:=RANDINT(10,1,18)*12;
costr:=CHAR(36); // $ sign
FOR I FROM 1 TO 10 DO
cx:=L2(I); cy:=L3(I);
TEXTOUT_P(costr,cx,cy,2,#FF00h);
END;
// House setup
LOCAL hx,hy,hstr;
hx:=RANDINT(0,31)*10;
hy:=0;
hstr:=CHAR(9820); // castle
TEXTOUT_P(hstr,hx,hy,2,#964B00h);
// Lock setup
LOCAL lock:=1;
// Movement
REPEAT
K:=GETKEY;
// move
IF K==7 AND A>0 THEN
C:=A10; D:=B;
END;
IF K==8 AND A<310 THEN
C:=A+10; D:=B;
END;
IF K==12 AND B<216 THEN
C:=A; D:=B+12;
END;
IF K==2 AND B>0 THEN
C:=A; D:=B12;
END;
// Bump in the boundary?
LOCAL collide:=0;
IF D==hy AND lock==1 THEN
collide:=1;
// No BREAK command because there is no
// FOR loop to break out of
END;
IF collide==1 THEN
C:=A; D:=B;
END;
// Collect the coin?
FOR I FROM 1 TO 10 DO
IF C==L2(I) AND D==L3(I) THEN
L2(I):=1;
L3(I):=1;
// Remove coin from play
coins:=coins1;
IF coins==0 THEN lock:=0 END;
BREAK;
END;
END;
// Player
RECT_P(A,B,A+10,B+12);
TEXTOUT_P("π",C,D,2);
// Draw a boundary
IF coins≠0 THEN
LINE_P(0,12,319,12,#FF0000h);
ELSE
// Unlock boundary, all coins collected
LINE_P(0,12,319,12,#FF00h);
END;
// Draw Static Objects
TEXTOUT_P(hstr,hx,hy,2,#964B00h);
FOR I FROM 1 TO 10 DO
cx:=L2(I); cy:=L3(I);
// Don't draw at 1
IF L2(I)≠−1 AND L3(I)≠1 THEN
TEXTOUT_P(costr,cx,cy,2,#FF00h);
END;
END;
// Draw Status Screen
RECT_P(0,217,319,239);
TEXTOUT_P(STRING(IP(coins)),0,228,2);
// Prepare
for the next move
A:=C; B:=D;
// Arrived home?
UNTIL K==50 OR (C==hx AND D==hy);
MSGBOX("Home! :)");
END;
Foes, coins, and trees will be combined in the next game.
Eddie
This blog is property of Edward Shore. 2014
A blog is that is all about mathematics and calculators, two of my passions in life.
Subscribe to:
Post Comments (Atom)
Retro Review: Radio Shack EC2024
Retro Review: Radio Shack EC2024 Quick Facts Company: Radio Shack Years in Production: Around 1994 Original Price: $24.99 Bat...

Casio fx991EX Classwiz Review Casio FX991EX The next incarnation of the fx991 line of Casio calculators is the fx991 EX. ...

The Odds of Hitting it Big The number of possible combinations is fairly easy to calculate. You multiply the number symbols each slot has ...

HP Prime: Basic CAS Commands for Polynomials and Rational Expressions Define the following variables: poly: a polynomial o...
No comments:
Post a Comment