iphonelazext: improved iArkanoid sample graphics and performance

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1142 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
skalogryz
2010-01-25 22:32:47 +00:00
parent aa19109f91
commit 7d79873fce
2 changed files with 12 additions and 21 deletions

View File

@ -253,16 +253,8 @@ begin
end; end;
if (cy >= PaddleY-5) and (cx >= PaddleX) and (cx <= PaddleX + PaddleW) and (dy>0) then begin if (cy >= PaddleY-5) and (cx >= PaddleX) and (cx <= PaddleX + PaddleW) and (dy>0) then begin
t := (cx - PaddleX - PaddleW/2) / (PaddleW/2); t := (cx - PaddleX) / PaddleW;
t:=pi*(1-(t*0.8+0.1));
if t > 1 then t := 1
else if t < -1 then t:=-1;
if t < 0 then
t := pi/2 + pi/16 - t / 2
else
t := pi/2 - pi/16 - t / 2;
dx := cos(t)*ballVelocity; dx := cos(t)*ballVelocity;
dy := -sin(t)*ballVelocity; dy := -sin(t)*ballVelocity;
cy := PaddleY-5; cy := PaddleY-5;
@ -290,10 +282,8 @@ begin
with Balls[i] do begin with Balls[i] do begin
x := PaddleX+PaddleW/2; x := PaddleX+PaddleW/2;
y := PaddleY-5; y := PaddleY-5;
//a := random*pi/4 + (pi/2 - pi/8); a := random*pi/4 + (pi/2 - pi/8);
//if cos(a)*5 < 0.1 then a := a + pi/5; if cos(a)*5 < 0.1 then a := a + pi/5;
//a:=5*pi/4;
a:=3*pi/2;
dx := ballVelocity*cos(a); dx := ballVelocity*cos(a);
dy := ballVelocity*sin(a); dy := ballVelocity*sin(a);
sticked:=true; sticked:=true;

View File

@ -91,12 +91,8 @@ begin
CGContextFillRect(ctx, r); CGContextFillRect(ctx, r);
for i := 0 to game.brickCount - 1 do begin for i := 0 to game.brickCount - 1 do begin
if game.bricks[i].flash > 0 then begin
MakeCGRect(game.bricks[i].bounds, r); MakeCGRect(game.bricks[i].bounds, r);
CGContextSetRGBFillColor(ctx, 1, 1, 1, 1); if game.bricks[i].health > 0 then begin
CGContextFillRect(ctx, r);
dec(game.bricks[i].flash);
end else if game.bricks[i].health > 0 then begin
MakeCGRect(game.bricks[i].bounds, r); MakeCGRect(game.bricks[i].bounds, r);
CGContextSetRGBFillColor(ctx, 1, 0, 0, 1); CGContextSetRGBFillColor(ctx, 1, 0, 0, 1);
CGContextFillRect(ctx, r); CGContextFillRect(ctx, r);
@ -107,6 +103,11 @@ begin
CGContextSetRGBFillColor(ctx, 0.8, 0, 0, 1); CGContextSetRGBFillColor(ctx, 0.8, 0, 0, 1);
CGContextFillRect(ctx, r); CGContextFillRect(ctx, r);
end; end;
if game.bricks[i].flash > 0 then begin
CGContextSetRGBFillColor(ctx, 1, 1, 1, 1/(game.bricks[i].flash+1));
CGContextFillRect(ctx, r);
dec(game.bricks[i].flash);
end;
end; end;
end; end;
@ -124,7 +125,7 @@ procedure MyMainWindow.initObjects;
begin begin
{ create timer } { create timer }
timer := NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats( timer := NSTimer.scheduledTimerWithTimeInterval_target_selector_userInfo_repeats(
double(0.1), Self, objcselector(timerEvent_), nil, true); double(0.075), Self, objcselector(timerEvent_), nil, true);
game := TArkanoid.Create(300, 400); game := TArkanoid.Create(300, 400);
game.Init; game.Init;
end; end;