c1.Y:=tux[20].Pos.Y;
c1.X:=tux[20].Pos.X;
c1.W:=64;
c1.H:=64;
for i := 0 to 19 do
begin
c2.Y:=tux[i].Pos.Y;
c2.X:=tux[i].Pos.X;
c2.W:=64;
c2.H:=64;
if (col2d_RectInRect(C1,C2)) then
tux[i].Killed:= true;
end;
end;
TTux = record
Texture : zglPTexture;
Frame : Integer;
Pos : zglTPoint2D;
DeltaX : single;
DeltaY : single;
Killed : Boolean;
end;
if not tux[ i ].Killed then
asprite2d_Draw( tux[ i ].Texture, tux[ i ].Pos.X, tux[ i ].Pos.Y, 64, 64, 0, tux[ i ].Frame div 2, 255, FX_BLEND or FX_COLOR );
procedure Timer;
var
i : Integer;
c1, c2:zglTRect;
begin
INC( time, 2 );
for i := 0 to 20 do
begin
INC( tux[ i ].Frame );
if tux[ i ].Frame > 20 Then
tux[ i ].Frame := 2;
end;
for i := 0 to 9 do
begin
tux[ i ].Pos.X := tux[ i ].Pos.X + 1.5;
if tux[ i ].Pos.X > 864 Then
tux[ i ].Pos.X := -96;
end;
for i := 10 to 19 do
begin
tux[ i ].Pos.X := tux[ i ].Pos.X - 1.5;
if tux[ i ].Pos.X < -96 Then
tux[ i ].Pos.X := 864;
end;
if key_Press( K_ESCAPE ) Then zgl_Exit();
if key_Down( K_UP ) Then
tux[ 20 ].Pos.Y := tux[ 20 ].Pos.Y - tux[ 20 ].DeltaY;
if key_Down( K_DOWN ) Then
tux[ 20 ].Pos.Y := tux[ 20 ].Pos.Y + tux[ 20 ].DeltaY;
if key_Down( K_LEFT ) Then
tux[ 20 ].Pos.X := tux[ 20 ].Pos.X - tux[ 20 ].DeltaX;
if key_Down( K_RIGHT ) Then
tux[ 20 ].Pos.X := tux[ 20 ].Pos.X + tux[ 20 ].DeltaX;
// nomorelogic: joypad movimento "analogico"
tux[ 20 ].Pos.X := tux[ 20 ].Pos.X + (tux[ 20 ].DeltaX * joy_AxisPos( 0, JOY_AXIS_X ));
tux[ 20 ].Pos.Y := tux[ 20 ].Pos.Y + (tux[ 20 ].DeltaY * joy_AxisPos( 0, JOY_AXIS_Y ));
// nomorelogic: joypad movimento "digitale"
tux[ 20 ].Pos.X := tux[ 20 ].Pos.X + (tux[ 20 ].DeltaX * joy_AxisPos( 0, JOY_POVX ));
tux[ 20 ].Pos.Y := tux[ 20 ].Pos.Y + (tux[ 20 ].DeltaY * joy_AxisPos( 0, JOY_POVY ));
key_ClearState();
joy_ClearState();
c1.Y:=tux[20].Pos.Y;
c1.X:=tux[20].Pos.X;
c1.W:=64;
c1.H:=64;
for i := 0 to 19 do
begin
c2.Y:=tux[i].Pos.Y;
c2.X:=tux[i].Pos.X;
c2.W:=64;
c2.H:=64;
if (col2d_RectInRect(C1,C2)) then
tux[i].Killed:= true;
end;
end;
for i := 0 to 9 do
if i = 2 Then
begin
// EN: Render the text in frame over penguins.
t := text_GetWidth( fntMain, 'I''m so red...' ) * 0.75 + 4;
pr2d_Rect( tux[ i ].Pos.X - 2, tux[ i ].Pos.Y - fntMain.MaxHeight + 4, t, fntMain.MaxHeight, $000000, 200, PR2D_FILL );
pr2d_Rect( tux[ i ].Pos.X - 2, tux[ i ].Pos.Y - fntMain.MaxHeight + 4, t, fntMain.MaxHeight, $FFFFFF );
text_DrawEx( fntMain, tux[ i ].Pos.X, tux[ i ].Pos.Y - fntMain.MaxHeight + 8, 0.75, 0, 'I''m so red...' );
// EN: Render red penguin using fx2d-function and flag FX_COLOR.
fx2d_SetColor( $FF0000 );
if not tux[ i ].Killed then
asprite2d_Draw( tux[ i ].Texture, tux[ i ].Pos.X, tux[ i ].Pos.Y, 64, 64, 0, tux[ i ].Frame div 2, 255, FX_BLEND or FX_COLOR );
end else
if i = 7 Then
begin
t := text_GetWidth( fntMain, '???' ) * 0.75 + 4;
pr2d_Rect( tux[ i ].Pos.X + 32 - t / 2, tux[ i ].Pos.Y - fntMain.MaxHeight + 4, t, fntMain.MaxHeight, $000000, 200, PR2D_FILL );
pr2d_Rect( tux[ i ].Pos.X + 32 - t / 2, tux[ i ].Pos.Y - fntMain.MaxHeight + 4, t, fntMain.MaxHeight, $FFFFFF );
text_DrawEx( fntMain, tux[ i ].Pos.X + 32, tux[ i ].Pos.Y - fntMain.MaxHeight + 8, 0.75, 0, '???', 255, $FFFFFF, TEXT_HALIGN_CENTER );
// EN: Render penguin ghost using flag FX_COLOR and mode FX_COLOR_SET :)
fx_SetColorMode( FX_COLOR_SET );
fx2d_SetColor( $FFFFFF );
if not tux[ i ].Killed then
asprite2d_Draw( tux[ i ].Texture, tux[ i ].Pos.X, tux[ i ].Pos.Y, 64, 64, 0, tux[ i ].Frame div 2, 155, FX_BLEND or FX_COLOR );
// EN: Return default mode.
fx_SetColorMode( FX_COLOR_MIX );
end else
if not tux[ i ].Killed then
asprite2d_Draw( tux[ i ].Texture, tux[ i ].Pos.X, tux[ i ].Pos.Y, 64, 64, 0, tux[ i ].Frame div 2 );
// EN: Render penguins, that go another way using special flag for flipping texture - FX2D_FLIPX.
for i := 10 to 19 do
if i = 13 Then
begin
t := text_GetWidth( fntMain, 'I''m so big...' ) * 0.75 + 4;
pr2d_Rect( tux[ i ].Pos.X - 2, tux[ i ].Pos.Y - fntMain.MaxHeight - 10, t, fntMain.MaxHeight, $000000, 200, PR2D_FILL );
pr2d_Rect( tux[ i ].Pos.X - 2, tux[ i ].Pos.Y - fntMain.MaxHeight - 10, t, fntMain.MaxHeight, $FFFFFF );
text_DrawEx( fntMain, tux[ i ].Pos.X, tux[ i ].Pos.Y - fntMain.MaxHeight - 4, 0.75, 0, 'I''m so big...' );
// EN: Render "big" penguin. It must be shifted up, because FX2D_SCALE scale sprite relative to the center.
fx2d_SetScale( 1.25, 1.25 );
if not tux[ i ].Killed then
asprite2d_Draw( tux[ i ].Texture, tux[ i ].Pos.X, tux[ i ].Pos.Y - 8, 64, 64, 0, tux[ i ].Frame div 2, 255, FX_BLEND or FX2D_FLIPX or FX2D_SCALE );
end else
if i = 17 Then
begin
// EN: Render "tall" penguin using flag FX2D_VCHANGE instead of FX2D_SCALE, and function fx2d_SetVertexes for
// shifting upper vertexes of sprite.
fx2d_SetVertexes( 0, -16, 0, -16, 0, 0, 0, 0 );
if not tux[ i ].Killed then
asprite2d_Draw( tux[ i ].Texture, tux[ i ].Pos.X, tux[ i ].Pos.Y, 64, 64, 0, tux[ i ].Frame div 2, 255, FX_BLEND or FX2D_FLIPX or FX2D_VCHANGE );
end else
if not tux[ i ].Killed then
asprite2d_Draw( tux[ i ].Texture, tux[ i ].Pos.X, tux[ i ].Pos.Y, 64, 64, 0, tux[ i ].Frame div 2, 255, FX_BLEND or FX2D_FLIPX );
procedure Draw;
var
i : Integer;
t : Single;
begin
batch2d_Begin();
if time > 255 Then
begin
zgl_Disable( COLOR_BUFFER_CLEAR );
back0_offset:= (time div 10) mod 800;
back1_offset:= (time div 3) mod 1600;
ssprite2d_Draw( texBack, -back0_offset, 0, 1600, 600, 0 );
ssprite2d_Draw( texBack1, -back1_offset, 400, 1600, 200, 0 );
if back1_offset > 800 then
ssprite2d_Draw( texBack1, -(back1_offset mod 800-800), 400, 1600, 200, 0 );
text_Draw( fntMain, 0, 25, 'time: ' + u_IntToStr( time ) );
text_Draw( fntMain, 0, 50, 'sfondo 0 offset: ' + u_IntToStr( back0_offset ) );
text_Draw( fntMain, 0, 75, 'sfondo 1 offset: ' + u_IntToStr( back1_offset ) );
cam2d_Set( @camMain );
for i := 0 to 20 do
begin
if not tux[ i ].Killed then
asprite2d_Draw( tux[ i ].Texture, tux[ i ].Pos.X, tux[ i ].Pos.Y, 64, 64, 0, tux[ i ].Frame div 2, 255, FX_BLEND );
end;
asprite2d_Draw( nave.Texture, nave.Pos.X, nave.Pos.Y, 64, 64, 0, nave.Frame div 2 );
end;
if time <= 255 Then
ssprite2d_Draw( texLogo, 400 - 256, 300 - 128, 512, 256, 0, time )
else
if time < 510 Then
begin
ssprite2d_Draw( texLogo, 400 - 256, 300 - 128, 512, 256, 0, 510 - time );
end;
if time > 255 Then
text_Draw( fntMain, 0, 0, 'FPS: ' + u_IntToStr( zgl_Get( RENDER_FPS ) ) );
DrawDebugInfo_Joy;
batch2d_End();
end;
zgl_collision_2d
Scusa , ma Castle non è piu' semplice ? Io non mi trovo molto con ZenGl ! Provo a vedere con castle cosa esce fuori ! Ciao Sergio