////////////////////////////////// // BOUNCING BALL GPU EXAMPLE // ////////////////////////////////// dentrypoint 0,_draw; // Set draw start entrypoint to "_draw" // rand #ball.x; // Set random ball start point rand #ball.y; // // dexit; // Exit the initialization routine... ////////////////////////////////// _draw: // Entrypoint for the drawing function // dcvxpipe 2; // Set coordinate pipe to 2 (to use coordinates 0...1) dclrscr bg_color; // Clear screen with background color // dmuldt eax,#d.x; // EAX = Direction Vector * Delta (change of coords per frame) add #ball.x,eax; // Move the ball dmuldt eax,#d.y; // add #ball.y,eax; // // cmp #ball.x,0.9; // Check hits against walls cge bounce.x; // Call bounce routine... cmp #ball.x,0.0; // cle bounce.x; // // cmp #ball.y,0.9; // Bounce on other axis cge bounce.y; // cmp #ball.y,0.0; // cle bounce.y; // // dcolor ball_color; // Set color to color of ball drectwh ball,ball_wh; // Draw the ball // dsetsize 24; // Set font size dwrite textpos,text; // dexit; // Exit the draw function ////////////////////////////////// bounce.x: // Bounce function (change X speed) neg #d.x; // min #ball.x,0.9; // max #ball.x,0.0; // ret // // bounce.y: // Bounce function (change Y speed) neg #d.y; // min #ball.y,0.9; // max #ball.y,0.0; // ret // ////////////////////////////////// // Data and resources // ////////////////////////////////// // color ball_color,255,255,255; // Ball color (white) color bg_color, 64, 32,128; // Background color (neon violet) // vector2f ball; // Ball position vector2f ball_wh,0.1,0.1; // Ball width/height // vector2f textpos,0.1,0.1; // Text position // vector2f d,1.0,1.0; // Movement direction & speed // string text,'Bouncing ball!'; // "Bouncing ball!" //////////////////////////////////