Post Reply 
PONG & SHUTTLE
03-09-2014, 11:21 AM
Post: #3
RE: PONG & SHUTTLE
Thanks for sharing. The shuttle is a total show off application ha ha ha.
Pong is far from being fluid. I had started something which was I think a bit better (especially on the physical device) but then I lost interest and never spent more time. May be the frame rate would have dropped once completed... I deleted the WIP topic, so here is the original code if anybody interested in working on it.
Code:

EXPORT Pong()
begin
local col,m,vx,vy,x,y,cmp,ply;
local t,frame;
local bounce:={{.342,.940},{.707,.707},{.866,.5},{1,0}};
 
dimgrob_p(G1, 320, 240); // Background
dimgrob_p(G2, 320, 240); // Playground
col:=RGB(255,255,255);
//col:=#17DD66h; // Green

// 29*8 x 40*8

// Frame
rect_p(G1,0,0,319,231,col);
rect_p(G1,8,8,312,223,0);
// Net
for y:=8 to 224 step 16 do rect_p(G1,156,y,163,y+7,col); end;

cmp:=14*8;
ply:=14*8;
vx:=bounce(1,1)*5;
vy:=bounce(1,2)*5;
frame:=0;

// Game loop
repeat
   t:=ticks+20;
   //Move the player
   m:=MOUSE;
   if size(m(1))>0 then
      if m(1,2)>ply then 
         ply:=ply+5;
         if ply>191 then ply:=191; end;
      end;
      if m(1,2)<ply then 
         ply:=ply-5; 
         if ply<9 then ply:=9; end;
      end;
   end;

   //Move the opponent
   frame:=frame+1;
   if frame mod IP(8-x/40+1) > 0 then
      if y>cmp+12 then
         cmp:=cmp+5;
         if cmp>191 then cmp:=191; end;
      end;
      if y<cmp+12 then 
         cmp:=cmp-5;
         if cmp<9 then cmp:=9; end;
      end;
   end;

   // Move the ball
   x:=x+vx;
   y:=y+vy;
   if y<8 then y:=8; vy:=-vy; end;
   if y>215 then y:=215; vy:=-vy; end;
   if x<8 then x:=8; vx:=-vx; end;
   if x>304 then x:=304; vx:=-vx; end;

   // Background
   blit_p(G2,G1);
   // Players
   rect_p(G2,9,cmp,16,cmp+31,col);
   rect_p(G2,304,ply,311,ply+31,col);
   // Ball
   rect_p(G2,x,y,x+7,y+7,col);

   while ticks<t do t:=t; end;

   // Final result
   blit_p(G0,G2);
until iskeydown(4);
wait(0);
end;
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
PONG & SHUTTLE - Jurgen Keller - 03-07-2014, 09:24 PM
RE: PONG & SHUTTLE - Mic - 03-08-2014, 07:07 AM
RE: PONG & SHUTTLE - Tugdual - 03-09-2014 11:21 AM
RE: PONG & SHUTTLE - Jurgen Keller - 03-10-2014, 08:47 PM



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