X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pages%2Fblog-0022.html-inc;h=bdf8c943171934678012135f98afb59a5caacb0b;hb=6855e5615bff699e656bdd67be71ac965fc77f54;hp=0de3c832cedb93b3d65e9876f3ff91874c42d50a;hpb=c8ad4fe9f211e727310a1ce6d23ffb1d7822d71f;p=sdlgit%2FSDL-Site.git diff --git a/pages/blog-0022.html-inc b/pages/blog-0022.html-inc index 0de3c83..bdf8c94 100644 --- a/pages/blog-0022.html-inc +++ b/pages/blog-0022.html-inc @@ -1,59 +1,31 @@

-Once in a while .... (set_event_filter) +Quick Game for Toronto Perl Mongers

-

-Once in a while
-Things just work!
-

-

+
+
Beep ... Boop
+


-So I have been hacking for a while on SDL::Events::set_event_filter. The code below is an example usage. The magic behind this is here
+So I am preparing a presentation of the new SDL perl for February's Toronto Perl Mongers meeting. What better way to so off SDL perl then with a game?

-
 1 #!/usr/bin/perl -w
- 2 use strict;
- 3 use warnings;
- 4 use SDL v2.3; #Require the redesign branch
- 5 use SDL::Video;
- 6 use SDL::Event;
- 7 use SDL::Events;
- 8 
- 9 SDL::init(SDL_INIT_VIDEO);
-10 my $display = SDL::Video::set_video_mode(640,480,32, SDL_SWSURFACE );
-11 my  $event = SDL::Event->new();
-12 
-13 #This filters out all ActiveEvents
-14 my $filter = sub { 
-15      my ($e, $type) = ($_[0], $_[0]->type); 
-16      if($type == SDL_ACTIVEEVENT){ return 0 } 
-17      elsif($type == SDL_MOUSEBUTTONDOWN && $e->button_button == 1){ return 0 }
-18      else { return 1; }
-19       };
-20 
-21 SDL::Events::set_event_filter($filter);
-22 
-23 while(1)
-24 {
-25 
-26   SDL::Events::pump_events();
-27   if(SDL::Events::poll_event($event))
-28   {
-29 
-30   if(  $event->type == SDL_ACTIVEEVENT)
-31  {
-32  print "Hello Mouse!!!\n" if ($event->active_gain && ($event->active_state == SDL_APPMOUSEFOCUS) );
-33  print "Bye Mouse!!!\n" if (!$event->active_gain && ($event->active_state == SDL_APPMOUSEFOCUS) );
-34         }
-35   if( $event->type == SDL_MOUSEBUTTONDOWN)
-36    {
-37  my ($x, $y, $but ) = ($event->button_x, $event->button_y, $event->button_button);
-38  warn "$but CLICK!!! at $x and $y \n";
-39  }
-40 
-41       last if($event->type == SDL_QUIT);
-42   }
-43 }
-44 SDL::quit()
 
 
Tinker with $filter and look at perldoc lib/SDL/pods/Event.pod. 
 
Have fun,
--yapgh
-


-

\ No newline at end of file +I started hacking a small point an click game a few days back. I really didn't have a idea in mind, but I did have a goal. I wanted to make a game that shows the basics of a game in SDL. Drawing to screen, game loops, physics and so on. I think I have accomplished it so far.
+
+Take a look at it here. Download that and call it[Shooter.pl]. To win click the balls.
+
+To play this game you need the following:
+
+
+I will put up binaries soon-ish.
+
+It is a playable (albeit hard) game right now. All 7 seven levels of it. The purpose of the game is simple click the balls to win. Sounds easy but it isn't. You also get a time in milliseconds after each level. Share your scores on here! I will leave it up to you guys to be honest.
+
+I do have to tidy it up and right documentation for it. This way I will be able to present it clearly to my fellow mongers. I am also still looking for ideas to make this a more polished game. FROGGS recommend I make it a classic NES duck hunt game. I thought since I am using gravity I could do a UFO game out of it where you shoot the UFOs. I am open to your ideas.
+


+

\ No newline at end of file