Sponsored Content
Special Forums Hardware Filesystems, Disks and Memory how to create screensaver for unix in java?? Post 66982 by madatyou1 on Saturday 19th of March 2005 01:53:46 PM
Old 03-19-2005
how to create screensaver for unix in java??

i would like to create a screensaver for unix platform in java. with an interface through which i can change the kinds of *.jpg images that r being displayed and also the background music. i don't know how to go about it. can anyone help please Smilie
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Screensaver and 'fortune'

(SuSE Linux 8.2 Personal) I'm sure the answer to this will be simple, but it's been driving me insane for the last couple days. SuSE 8.2 comes with a bunch of screensavers, but a handful of them just repeatedly display 'sh: line 1: fortune: command not found'. I've been scouring endlessly... (4 Replies)
Discussion started by: Darkstripes
4 Replies

2. HP-UX

create thread C with JNI function with JAVA

Hello, J create a thread C with a JNI function via JAVA. J have the following message (but not in each time): Someone has an idea ? Thank. Unexpected Signal : 4 occurred at PC=0x78C103E0 Function= Library=(N/A) NOTE: We are unable to locate the function name... (0 Replies)
Discussion started by: AUBERT
0 Replies

3. UNIX for Advanced & Expert Users

Move mouse to disable screensaver?

All XKCD jokes aside, can a feature be added to a bash script to move the mouse every X seconds to prevent the screensaver from activating? As is it, I launch mplayer through a script that sets some preferences (such as -zoom). Can I add something to that script which wiggles the mouse? Relevant... (1 Reply)
Discussion started by: dotancohen
1 Replies

4. Solaris

ScreenSaver issue with Solaris 10

I have a Dell Vostro running Solaris 10 x86 and I am trying to get it to activate the screensaver when no one is logged it. However, the screensaver only seems to activate when someone logs in and then the computer locks. How would I go about fixing this problem? Any help yall can offer would be... (3 Replies)
Discussion started by: MajorJRO
3 Replies

5. UNIX for Dummies Questions & Answers

ScreenSaver into Background Question

(Keeping in mind I know very little about Unix...) When I am typing this out (without copy-pasting the whole thing) to get my screensaver onto my background: /System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background I... (3 Replies)
Discussion started by: wat_up_m
3 Replies

6. Programming

How to create java based dictionary for mobile using data in microsoft excel?

i am having a ms excel file which contains 2 columns, I first column i added words, and in second column meaning to the word in the first column. I want to create a dictionary for mobile like nokia or any java based application running mobile. How it can be created as i, dont know the java... (1 Reply)
Discussion started by: Anna Hussie
1 Replies

7. Programming

Need best forum site for java (as for unix its unix.com)

Hi All, Can anyone help me for knowing the java best side forums. where i will get a quick responce like here , as i am having lot of question. Thanks (1 Reply)
Discussion started by: aish11
1 Replies

8. Programming

JAVA code to create file in Linux with specific permission

Hi All, I'm looking for JAVA code to create file in Linux with specific permission File should be created and saved in Linux in this path \opt\sys\doc by Java with this permission 764 Anyone can help to provide this Java code (3 Replies)
Discussion started by: AbuAliiiiiiiiii
3 Replies
pods::SDL::Tutorial::LunarLander(3pm)			User Contributed Perl Documentation		     pods::SDL::Tutorial::LunarLander(3pm)

NAME
SDL::Tutorial::LunarLander - a small tutorial on Perl SDL CATEGORY Tutorials INTRODUCTION
This is a quick introduction to Games, Perl, and SDL (Simple DirectMedia Layer, a cross-platform multimedia programming library). We'll write a small game -- Lunar Lander -- in 100 lines of code, or less. CREATING A DEMO You can see the final version of the demo code by doing: perl -MSDL::Tutorial::LunarLander=lander.pl -e1 this will create all three files used in the tutorial. FIRST VERSION We'll start with a text version of the game. "What?", you may ask. "I thought it was a SDL tutorial". Yes, it is -- thank you for reminding me. But we'll leave the SDL part for later. We must build the game logic first! One of the traps of game programming is focusing too much on the interface. If we start with a simpler simulation, we can worry with the presentation later. So, here's the initial code: #!/usr/bin/perl use strict; use warnings; my $height = 1000; # m my $velocity = 0; # m/s my $gravity = 1; # m/s^2 my $t = 0; while ( $height > 0 ) { print "at $t s height = $height m, velocity = $velocity m/s "; $height = $height - $velocity; $velocity = $velocity + $gravity; $t = $t + 1; } if ( $velocity > 10 ) { print "CRASH!!! "; } else { print "You landed on the surface safely! :-D "; } Run the code and you'll see something like this: at 0 s height = 1000 m, velocity = 0 m/s at 1 s height = 1000 m, velocity = 1 m/s at 2 s height = 999 m, velocity = 2 m/s at 3 s height = 997 m, velocity = 3 m/s at 4 s height = 994 m, velocity = 4 m/s at 5 s height = 990 m, velocity = 5 m/s ... at 43 s height = 97 m, velocity = 43 m/s at 44 s height = 54 m, velocity = 44 m/s at 45 s height = 10 m, velocity = 45 m/s CRASH!!! "What happened? How do I control the ship???" CONTROLLING THE SHIP The problem with our first spaceship is that it had no controls! So, let's fix this problem, making the spaceship scriptable. (We could write some code to handle keyboard and joysticks now, but an scriptable spaceship will be easier to start. Remember, focus on the game logic!) So, create add this simple script to the end of your file: __DATA__ at 41s, accelerate 10 m/s^2 up at 43s, 10 m/s^2 at 45s, 10 at 47s, 10 at 49s, 10 The script is straightforward: it simply states a time when we will push the spaceship up with a given acceleration. It accepts free text: any two numbers you type will work. We can parse the script using this regular expression: my $script_re = qr/(d+) D+ (d+)/x; And we can build a hash of ( time => acceleration ) with: my %up = map { $_ =~ $script_re } <DATA>; So the middle section of the program will become: my $script_re = qr/(d+) D+ (d+)/x; my %up = map { $_ =~ $script_re } <DATA>; while ( $height > 0 ) { print "at $t s height = $height m, velocity = $velocity m/s "; if ( $up{$t} ) { my $a = $up{$t}; print "(accelerating $a m/s^2) "; $velocity = $velocity - $a; } $height = $height - $velocity; $velocity = $velocity + $gravity; $t = $t + 1; } That's it! Try to run the program, and the ship should land safely: ./lunar.pl autopilot.txt at 0 s height = 1000 m, velocity = 0 m/s at 1 s height = 1000 m, velocity = 1 m/s at 2 s height = 999 m, velocity = 2 m/s at 3 s height = 997 m, velocity = 3 m/s at 4 s height = 994 m, velocity = 4 m/s at 5 s height = 990 m, velocity = 5 m/s ... at 54 s height = 19 m, velocity = 4 m/s at 55 s height = 15 m, velocity = 5 m/s at 56 s height = 10 m, velocity = 6 m/s at 57 s height = 4 m, velocity = 7 m/s You landed on the surface safely! :-D Cool, but... HOW ABOUT THE GRAPHICS? Okay, okay... now that we have a working prototype, we can work on the graphics. But, first of all, we'll need... THE GRAPHICS Yes, the graphics. We won't use anything fancy here, just two images: a large one, for the background, and a smaller one for the spaceship. Create the images using the Gimp, or use the images provided by this tutorial; Save these images in a subdirectory called "images": (""images/background.jpg"" and ""images/ship.png""). USING SDL First step: use the required libraries: use SDL; #needed to get all constants use SDL::Video; use SDLx::App; use SDL::Surface; use SDL::Rect; use SDL::Image; Second step: initialize "SDLx::App": my $app = SDLx::App->new( title => "Lunar Lander", width => 800, height => 600, depth => 32, ); Third step: load the images and create the necessary "rectangles": my $background = SDL::Image::load('images/background.jpg'); my $ship = SDL::Image::load('images/ship.jpg'); my $background_rect = SDL::Rect->new(0,0, $background->w, $background->h, ); my $ship_rect = SDL::Rect->new(0,0, $ship->w, $ship->h, ); Fourth step: create a sub to draw the spaceship and background: sub draw { my ( $x, $y ) = @_; # spaceship position # fix $y for screen resolution $y = 450 * ( 1000 - $y ) / 1000; # background SDL::Video::blit_surface($background, $background_rect, $app, $background_rect ); # ship my $ship_dest_rect = SDL::Rect->new( $x, $y, $ship->w, $ship->h, ); SDL::Video::blit_surface($ship, $ship_rect, $app, $ship_dest_rect ); SDL::Video::update_rects($app, $background_rect); } Note that this sub first combines all the bitmaps, using a blit ("Block Image Transfer") operation -- which is quite fast, but does not update the display. The combined image is displayed in the last line. This process of combining first, and displaying later, avoids that annoying fading between cycles ("flickering"). Finally, add the following lines to the end of the main loop, so that we call the "draw()" function with the correct spaceship coordinates: while ( $height > 0 ) { # ... draw( 100, $height ); $app->delay(10); } That's it! Run the program and watch the spaceship landing safely on the surface of the moon. COPYRIGHT &; LICENSE Copyright 2009 Nelson Ferraz, all rights reserved. Updated and maintained by the SDL Perl project. See "AUTHORS" in SDL. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-05-28 pods::SDL::Tutorial::LunarLander(3pm)
All times are GMT -4. The time now is 08:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy