Sidney's 6.837 Project 1 Applet
Welcome! Meet Svein Forkbeard! Svein the viking is on a stroll in the
forests of Norway. You can move Svein left and right in the forest
scene. But watch out for the snake! Svein is afraid of them.
Directions:
Left Directional Key - hit once to make Svein walk left and hit a
second time to make him stop
Right Directional Key - hit once to make Svein walk right and hit a
second time to make him stop
Space Bar - hit to make Svein jump in surprise
Mouse Click - click on the playfield to see if you hit Svein or the snake
My resources in creating the graphics for the applet:
Background forest scenery from
Maryann E. Sterlings's Art
Viking animated GIF from an
Animation Library on the web
Snake created by me using Paint Shop Pro and GIF MovieGear
I named my applet viking after the father of Canute the Great.
Notes about using the applet:
Please use Internet Explorer 4.0 to view the applet.
You must click on the applet before key events will register.
Running the applet in appletviewer is considerably faster.
Links to the source code:
Raster.java - The snake, viking, and forest
are all rasters. The raster will store all the pixels for a given image.
Sprite.java - The snake and viking are
sprites. They can draw themselves on a given background taking into
account clipping at the edges of the playfield and transparent
pixels. The sprite uses pixblts to save and replace the background it
covers.
AnimatedSprite.java - The snake and
viking are also animated sprites. An animated sprite contains a series
of frames of an animation and different tracks of those animations for
different movements. I also added some simple collision detection using
bounding boxes of the sprites to detect when Svein encounters the snake.
Playfield.java - The forest is a
playfield. A playfield contains all the sprites and calls each sprite's
Draw method when the world needs to be repainted.
Viking.java - The viking is its own class that
extends AnimatedSprite. Viking is responsible for controlling the
different possible states for the viking. Some states the viking can
take are walking left, walking right, standing, jumping left, and
jumping right.
Snake.java - The snake is its own class that
extends AnimatedSprite. Snake is responsible for controlling the
different possible states for the snake. Some states the snake can take
are slithering, startled, and coiled.
Project1.java - This is the driver for the applet.