HP Prime for All

English  Русский 
Trailblazer games-app screenshot}}
Name Trailblazer
Description Make the ball jump down the track without falling off the edge. Fun! An early work in progress.
Author Unknown

Source code (download):

Source code formatted by website engine

ICON resource lines were stripped.

// 0.0.5 // (maybe one day) // MacBernick 2013 // Work in progress ! EXPORT // General Settings showFPS := 0, minSpeed := 0.1, maxSpeed := 0.7, ballSpeed := 0.25, accel := 0.001; EXPORT trackMatrix, currentSpeed, camPosition, ballPosition, ballHeight, vFOV, timer; EXPORT rayTable, squareSize, obsDist, xEnds, ballLimits; EXPORT fps := 0, currentTile, falling, fallTime; EXPORT jumping := 0, jumpTable, jumpSpeed; init(); doRender(); dashboard(); EXPORT trailblazer() BEGIN LOCAL angleMode := HAngle; HAngle := 1; init(); // Main Loop LOCAL looping := 1, time := 0, mainTimer := TICKS, frames := 0, revControls := 0; timer := 0; WHILE looping DO time := TICKS; IF ISKEYDOWN(4) THEN // Quit looping := 0; END; IF NOT falling THEN // Keys IF (ISKEYDOWN(7) AND NOT revControls) OR (ISKEYDOWN(8) AND revControls) THEN // Left ballPosition := ballPosition - ballSpeed * timer; IF ballPosition < 0 THEN ballPosition := 0; END; END; IF (ISKEYDOWN(8) AND NOT revControls) OR (ISKEYDOWN(7) AND revControls) THEN // Right ballPosition := ballPosition + ballSpeed * timer; IF ballPosition > 294 THEN ballPosition := 294; END; END; IF (ISKEYDOWN(2) OR currentTile == 3) AND currentTile < > 4 THEN // Speed Up currentSpeed := currentSpeed + accel * timer; IF currentSpeed > maxSpeed THEN currentSpeed := maxSpeed; END; END; IF (ISKEYDOWN(12) OR currentTile == 4) AND currentTile < > 3 THEN // Slow Down currentSpeed := currentSpeed - accel * timer; IF currentSpeed < minSpeed THEN currentSpeed := minSpeed; END; END; IF NOT jumping AND (ISKEYDOWN(30) OR currentTile == 6) THEN // Jump jumping := 1; END; ELSE currentSpeed := currentSpeed - accel * timer; IF currentSpeed < 0 THEN currentSpeed := 0; END; IF TICKS - fallTime > = 2000 THEN falling := 0; jumping := 1; currentSpeed := 0.3; END; END; // Render Frame doRender(); dashboard(); // Display Frame BLIT(G1); // Move Camera camPosition := camPosition + currentSpeed * timer; IF camPosition > 10000 THEN camPosition := 0; END; // Frame counter IF showFPS THEN frames := frames + 1; IF TICKS - mainTimer > = 1000 THEN mainTimer := TICKS; fps := frames; frames := 0; END; END; IF NOT jumping AND NOT falling THEN IF ballPosition > = ballLimits(1) AND ballPosition < = ballLimits(2) THEN currentTile := trackMatrix( IP( ( rayTable(89) + camPosition ) / 64 + 1 ), IP( ( ballPosition - ballLimits(1) ) / ( ( ballLimits(2) - ballLimits(1) ) / 5 ) + 1 ) ); ELSE currentTile := 0; END; ELSE currentTile := 99; END; CASE IF currentTile == 5 AND NOT revControls THEN revControls := 1; END; IF (currentTile == 1 OR currentTile == 2) AND revControls THEN revControls := 0; END; IF (currentTile == 0) THEN falling := 1; fallTime := TICKS; END; END; timer := TICKS - time; END; // Leaving Program HAngle := angleMode; RETURN "Thank you !"; END; // Render Frame doRender() BEGIN LOCAL r, ray; // Clear Frame RECT(G1, 0); // Display falling ball IF falling THEN BLIT_P(G1, ballPosition, ballHeight, "ball", #FF00FF); ballHeight := ballHeight + 0.1 * timer; END; // Render Track FOR ray FROM 1 TO 119 STEP 2 DO BLIT_P(G1, xEnds(ray, 1), ray + 20, xEnds(ray, 2), ray + 24, G4, 0, (rayTable(ray) + camPosition) / 8, 160, (rayTable(ray) + camPosition) / 8, #FF00FF); END; // Fade Out FOR r FROM 20 to 30 DO FILLPOLY_P(G1, {{0, r}, {319, r}, {0, r + 1}, {319, r + 1}}, 0, (30 - r) * 255 / 20); END; // Display NOT falling ball IF NOT falling THEN // Jumping ? IF jumping THEN jumping := IP(jumping + jumpSpeed * timer); IF jumping < = 62 THEN ballHeight := jumpTable(jumping); ELSE jumping := 0; ballHeight := 85; END; END; // Ball and Shadow FILLPOLY_P(G1, {{ballPosition, 110}, {ballPosition + 26, 110}, {ballPosition + 26, 112}, {ballPosition, 112}}, 0, 128 - … FILLPOLY_P(G1, {{ballPosition + 5, 109}, {ballPosition + 21, 109}, {ballPosition + 21, 113}, {ballPosition + 5, 113}}, 0BLIT_P(G1, ballPosition, ballHeight, "ball", #FF00FF); END; // Display FPS IF showFPS THEN TEXTOUT_P(fps, G1, 2, 2, 1, #FF0000); END; END; // Dashboard Render dashboard() BEGIN RECT_P(G1, 0, 141, 340, 240, #1110FF); TEXTOUT_P("currentSpeed : " + currentSpeed, G1, 10, 160, 3, #FFFF00); END; // Init some values and do some Math init() BEGIN DIMGROB_P(G1, 320, 240); ballPosition := 147; ballHeight := 85; squareSize := 64; camPosition := 0; currentSpeed := minSpeed; jumpSpeed := 0.15; falling := 0; LOCAL vFOV := 30; LOCAL ray, col, x1t, x2t; //xCoefTable := {-2.5, 2.5}; obsDist := EVAL(120 / TAN(vFOV / 2)); // Projection Tables rayTable := {}; xEnds := {}; FOR ray FROM 121 TO 240 DO rayTable := append(rayTable, EVAL((28800 - 120 * ray) / (ray * TAN(vFOV / 2)))); xEnds := append(xEnds, { obsDist / (obsDist + rayTable(ray - 120)) * -2.5 * squareSize + 160, obsDist / (obsDist + rayTable(ray - 120)) * 2.5 * squareSize + 160}); END; ballLimits := {xEnds(89, 1) - 13, xEnds(89, 2) - 13}; // Jump height table jumpTable := {}; LOCAL r := 0; WHILE r < = 62 DO jumpTable := append(jumpTable, EVAL((r / 4 - sqrt(60))² + 25)); r := r + 1; END; // The Track trackMatrix := {{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 2, 1, 1}, {1, 2, 2, 2, 1}, {2, 2, 2, 2, 2}, {0// Track Megagrob DIMGROB_P(G4, 160, SIZE(trackMatrix) * 8, #FF00FF); LOCAL r, s; FOR r FROM 1 TO SIZE(trackMatrix) DO FOR s FROM 1 TO 5 DO IF trackMatrix(r, s) > 0 THEN BLIT_P(G4, (s - 1) * 32, (r - 1) * 8, "textures", (trackMatrix(r, s) - 1) * 32, 0, (trackMatrix(r, s)) * 32, 8); END END; END; // FOR r FROM 1 TO SIZE(trackMatrix) DO // FOR s FROM 1 TO 5 DO // IF trackMatrix(r, s) == 0 THEN // IF r < SIZE(trackMatrix) AND trackMatrix(r + 1, s) > 0 THEN // LINE_P(G4, (s - 1) * 32, r * 8 - 1, s * 32 - 1, r * 8 - 1, #AAAAAA); // LINE_P(G4, (s - 1) * 32 + 1, r * 8 - 2, s * 32 - 2, r * 8 - 2, #555555); // LINE_P(G4, (s - 1) * 32 + 2, r * 8 - 3, s * 32 - 3, r * 8 - 3, #222222); // LINE_P(G4, (s - 1) * 32 + 3, r * 8 - 4, s * 32 - 4, r * 8 - 4, #0F0F0F); // END; // END; // END; // END; END; // GFX ICON ball 89504E470D0A1A0A0000000D494844520000001A0000001A0203000000D424A45D00000009504C5445FF00FF000000FFFFFF58A489A900… ICON textures 89504E470D0A1A0A0000000D49484452000000C000000008080300000098B900EC0000029D504C544500C900005B0000920000AC00… ICON lights 89504E470D0A1A0A0000000D494844520000002A000000100403000000920CF0A30000001E504C5445FF00FFFFFFFF383838FF7D7DAF…

Comments