#!/usr/bin/perl
use strict;
use warnings;
use SDL;
use SDL::Events;
use SDLx::App;
use SDLx::Rect;
use SDLx::Text;
# create the main screen
my $app = SDLx::App->new(
width =>500,
height =>500,
title => 'New Game!',
dt => 0.02,
exit_on_quit => 1,
);
my $player = {
x => $app->w/2,
y => $app->h-20,
w => 80,
h => 20,
vel => 250,
y_vel => 0,
};
my $minge = {
x => $app->w/2,
y => $app->h/2,
dim => 10,
};
$app->add_show_handler( \&show);
$app->run;
sub show {
# first, clear the screen
$app->draw_rect( [0, 0, $app->width, $app->height], 0x000000FF);
$app->draw_rect([$player->{x}, $player->{y}, $player->{w}, $player->{h}], 0xFF0000FF);
$app->draw_circle_filled([$minge->{x}, $minge->{y}], $minge->{dim}, [0, 0,255, 255]);
$app->update();
}
-------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------
use strict;
use warnings;
use SDL;
use SDL::Events;
use SDLx::App;
use SDLx::Rect;
use SDLx::Text;
# create the main screen
my $app = SDLx::App->new(
width =>500,
height =>500,
title => 'New Game!',
dt => 0.02,
exit_on_quit => 1,
);
my $player = {
x => $app->w/2,
y => $app->h-20,
w => 80,
h => 20,
vel => 250,
y_vel => 0,
};
my $minge = {
x => $app->w/2,
y => $app->h/2,
dim => 10,
};
$app->add_show_handler( \&show);
$app->run;
sub show {
# first, clear the screen
$app->draw_rect( [0, 0, $app->width, $app->height], 0x000000FF);
$app->draw_rect([$player->{x}, $player->{y}, $player->{w}, $player->{h}], 0xFF0000FF);
$app->draw_circle_filled([$minge->{x}, $minge->{y}], $minge->{dim}, [0, 0,255, 255]);
$app->update();
}
-------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------
Niciun comentariu:
Trimiteți un comentariu