Computer Science Canada

Alien Attack - Animation

Author:  SkaarjSlayer [ Thu Sep 25, 2008 3:59 pm ]
Post subject:  Alien Attack - Animation

Hey guys, I had known about this site for a couple weeks but decided to finally register so yea I'm new here. I saw all these Turing submissions and thought I'd put in some of my own.

This particular program was one I wrote last year for school but after looking at it a bit this year, I decided to edit it and now it's a bit better.

It's not indented a whole lot as I seem to see you guys prefer and it doesn't have much internal documentation but bear with me!

This has 351 lines of code and is basically an animation portraying an alien attack on a city. Pretty simple and just to let you know the last, final explosion at the end is NOT my work and I had taken it from another person's program (don't remember which) but the smaller explosions in the animation are mine.

code:
% The Alien Assault: The Edited Version %

% Author: Cameron Gazey aka SkaarjSlayer
% Filename: island_edited.t
% Original Date Completed: Friday, April 18th, 2008
% Edited: Wednesday, September 10th, 2008
% A graphics cinematic portraying an alien attack on a city.

% background including the moon, sky, ocean, and island
Draw.FillBox (0,0,800,400,black)
Draw.FillOval (300,80,200,50,brown)
Draw.FillBox (0,0,800,100,blue)
Draw.FillOval (500,300,50,50,white)

% the city
Draw.FillBox (310, 130, 300, 160, darkgray)
Draw.FillBox (250, 125, 240, 155, darkgray)
Draw.FillBox (200, 120, 190, 150, darkgray)
Draw.FillBox (400, 120, 390, 150, darkgray)
Draw.FillBox (350, 125, 340, 180, darkgray)
Draw.FillBox (320, 125, 340, 140, gray)
Draw.FillBox (290, 125, 300, 140, gray)
Draw.FillBox (300, 125, 320, 135, darkgray)
Draw.FillBox (350, 125, 370, 150, gray)
Draw.FillBox (370, 125, 400, 140, darkgray)
Draw.FillBox (200, 124, 220, 130, gray)
Draw.FillBox (220, 125, 210, 160, gray)
Draw.FillBox (270, 125, 280, 170, darkgray)
Draw.FillBox (250, 125, 300, 135, gray)
Draw.FillBox (220, 125, 240, 135, darkgray)

% for loop for the moving and attacking alien ships
for i : 1..100
Draw.FillOval (200+i,350,150,25,gray)
Draw.FillOval (150+i,370,50,15,darkgray)
Draw.FillOval (350+i,300,30,10,darkgray)
Draw.FillOval (50+i, 280, 30, 10, darkgray)
delay (200)
Draw.FillOval (200+i,350,150,25,black)
Draw.FillOval (150+i,370,50,15,black)
Draw.FillOval (350+i,300,30,10,black)
Draw.FillOval (50+i, 280, 30, 10, black)
end for
Draw.FillOval (300, 350, 150, 25, gray)
Draw.FillOval (250, 370, 50, 15, darkgray)
Draw.FillOval (450, 300, 30, 10, darkgray)
Draw.FillOval (150, 280, 30, 10, darkgray)

delay (1000)

% lasers :)
for a : 1..50
delay (25)
Draw.DashedLine (150, 280, 200, 120, drawDot, yellow)
delay (25)
Draw.DashedLine (150, 280, 200, 120, drawDot, black)
delay (25)
Draw.DashedLine (450, 300, 370, 125, drawDot, yellow)
delay (25)
Draw.DashedLine (450, 300, 370, 125, drawDot, black)
end for

% redrawn ships and city to eliminate black dashed lines left over from the lasers
% redrawn ships
Draw.FillOval (450, 300, 30, 10, darkgray)
Draw.FillOval (150, 280, 30, 10, darkgray)
% redrawn city
Draw.FillBox (310, 130, 300, 160, darkgray)
Draw.FillBox (250, 125, 240, 155, darkgray)
Draw.FillBox (200, 120, 190, 150, darkgray)
Draw.FillBox (400, 120, 390, 150, darkgray)
Draw.FillBox (350, 125, 340, 180, darkgray)
Draw.FillBox (320, 125, 340, 140, gray)
Draw.FillBox (290, 125, 300, 140, gray)
Draw.FillBox (300, 125, 320, 135, darkgray)
Draw.FillBox (350, 125, 370, 150, gray)
Draw.FillBox (370, 125, 400, 140, darkgray)
Draw.FillBox (200, 124, 220, 130, gray)
Draw.FillBox (220, 125, 210, 160, gray)
Draw.FillBox (270, 125, 280, 170, darkgray)
Draw.FillBox (250, 125, 300, 135, gray)
Draw.FillBox (220, 125, 240, 135, darkgray)

% more lasers :)
for l : 1..50
delay (25)
Draw.DashedLine (150, 280, 400, 150, drawDot, yellow)
delay (25)
Draw.DashedLine (150, 280, 400, 150, drawDot, black)
delay (25)
Draw.DashedLine (450, 300, 300, 150, drawDot, yellow)
delay (25)
Draw.DashedLine (450, 300, 300, 150, drawDot, black)
end for

% more redrawing :(
% redrawn ships...again
Draw.FillOval (450, 300, 30, 10, darkgray)
Draw.FillOval (150, 280, 30, 10, darkgray)
% redrawn city...again :P
Draw.FillBox (310, 130, 300, 160, darkgray)
Draw.FillBox (250, 125, 240, 155, darkgray)
Draw.FillBox (200, 120, 190, 150, darkgray)
Draw.FillBox (400, 120, 390, 150, darkgray)
Draw.FillBox (350, 125, 340, 180, darkgray)
Draw.FillBox (320, 125, 340, 140, gray)
Draw.FillBox (290, 125, 300, 140, gray)
Draw.FillBox (300, 125, 320, 135, darkgray)
Draw.FillBox (350, 125, 370, 150, gray)
Draw.FillBox (370, 125, 400, 140, darkgray)
Draw.FillBox (200, 124, 220, 130, gray)
Draw.FillBox (220, 125, 210, 160, gray)
Draw.FillBox (270, 125, 280, 170, darkgray)
Draw.FillBox (250, 125, 300, 135, gray)
Draw.FillBox (220, 125, 240, 135, darkgray)

% aren't lasers just fun?
for o : 1..50
delay (25)
Draw.DashedLine (150, 280, 245, 130, drawDot, yellow)
delay (25)
Draw.DashedLine (150, 280, 245, 130, drawDot, black)
delay (25)
Draw.DashedLine (450, 300, 330, 140, drawDot, yellow)
delay (25)
Draw.DashedLine (450, 300, 330, 140, drawDot, black)
end for

% MORE redrawing -_-
% redrawn ships...again...again
Draw.FillOval (450, 300, 30, 10, darkgray)
Draw.FillOval (150, 280, 30, 10, darkgray)
% redrawn city...again...again
Draw.FillBox (310, 130, 300, 160, darkgray)
Draw.FillBox (250, 125, 240, 155, darkgray)
Draw.FillBox (200, 120, 190, 150, darkgray)
Draw.FillBox (400, 120, 390, 150, darkgray)
Draw.FillBox (350, 125, 340, 180, darkgray)
Draw.FillBox (320, 125, 340, 140, gray)
Draw.FillBox (290, 125, 300, 140, gray)
Draw.FillBox (300, 125, 320, 135, darkgray)
Draw.FillBox (350, 125, 370, 150, gray)
Draw.FillBox (370, 125, 400, 140, darkgray)
Draw.FillBox (200, 124, 220, 130, gray)
Draw.FillBox (220, 125, 210, 160, gray)
Draw.FillBox (270, 125, 280, 170, darkgray)
Draw.FillBox (250, 125, 300, 135, gray)
Draw.FillBox (220, 125, 240, 135, darkgray)

delay (1000)

% big laser XD
for z : 1..150
delay (25)
Draw.FillBox (300, 315-z, 310, 325, yellow)
end for
Draw.FillBox (300, 165, 310, 325, black)

% city explosions, explosions are put into 5 seperate for-loops executing 3 explosions each
% explosion set 1
for g : 1..10
delay (50)
Draw.FillOval (320, 125, 0+g, 0+g, brightred)
delay (50)
Draw.FillOval (200, 150, 0+g, 0+g, brightred)
delay (50)
Draw.FillOval (275, 125, 0+g, 0+g, brightred)
end for
Draw.FillBox (0,0,800,400,black)
Draw.FillOval (300,80,200,50,brown)
Draw.FillBox (0,0,800,100,blue)
Draw.FillOval (500,300,50,50,white)
Draw.FillBox (310, 130, 300, 160, darkgray)
Draw.FillBox (250, 125, 240, 155, darkgray)
Draw.FillBox (200, 120, 190, 150, darkgray)
Draw.FillBox (400, 120, 390, 150, darkgray)
Draw.FillBox (350, 125, 340, 180, darkgray)
Draw.FillBox (320, 125, 340, 140, gray)
Draw.FillBox (290, 125, 300, 140, gray)
Draw.FillBox (300, 125, 320, 135, darkgray)
Draw.FillBox (350, 125, 370, 150, gray)
Draw.FillBox (370, 125, 400, 140, darkgray)
Draw.FillBox (200, 124, 220, 130, gray)
Draw.FillBox (220, 125, 210, 160, gray)
Draw.FillBox (270, 125, 280, 170, darkgray)
Draw.FillBox (250, 125, 300, 135, gray)
Draw.FillBox (220, 125, 240, 135, darkgray)
Draw.FillOval (300, 350, 150, 25, gray)
Draw.FillOval (250, 370, 50, 15, darkgray)
Draw.FillOval (450, 300, 30, 10, darkgray)
Draw.FillOval (150, 280, 30, 10, darkgray)

% explosion set 2
for f : 1..10
delay (50)
Draw.FillOval (290, 130, 0+f, 0+f, brightred)
delay (50)
Draw.FillOval (360, 150, 0+f, 0+f, brightred)
delay (50)
Draw.FillOval (305, 125, 0+f, 0+f, brightred)
end for
Draw.FillBox (0,0,800,400,black)
Draw.FillOval (300,80,200,50,brown)
Draw.FillBox (0,0,800,100,blue)
Draw.FillOval (500,300,50,50,white)
Draw.FillBox (310, 130, 300, 160, darkgray)
Draw.FillBox (250, 125, 240, 155, darkgray)
Draw.FillBox (200, 120, 190, 150, darkgray)
Draw.FillBox (400, 120, 390, 150, darkgray)
Draw.FillBox (350, 125, 340, 180, darkgray)
Draw.FillBox (320, 125, 340, 140, gray)
Draw.FillBox (290, 125, 300, 140, gray)
Draw.FillBox (300, 125, 320, 135, darkgray)
Draw.FillBox (350, 125, 370, 150, gray)
Draw.FillBox (370, 125, 400, 140, darkgray)
Draw.FillBox (200, 124, 220, 130, gray)
Draw.FillBox (220, 125, 210, 160, gray)
Draw.FillBox (270, 125, 280, 170, darkgray)
Draw.FillBox (250, 125, 300, 135, gray)
Draw.FillBox (220, 125, 240, 135, darkgray)
Draw.FillOval (300, 350, 150, 25, gray)
Draw.FillOval (250, 370, 50, 15, darkgray)
Draw.FillOval (450, 300, 30, 10, darkgray)
Draw.FillOval (150, 280, 30, 10, darkgray)

% explosion set 3
for e : 1..10
delay (50)
Draw.FillOval (285, 120, 0+e, 0+e, brightred)
delay (50)
Draw.FillOval (320, 140, 0+e, 0+e, brightred)
delay (50)
Draw.FillOval (205, 120, 0+e, 0+e, brightred)
end for
Draw.FillBox (0,0,800,400,black)
Draw.FillOval (300,80,200,50,brown)
Draw.FillBox (0,0,800,100,blue)
Draw.FillOval (500,300,50,50,white)
Draw.FillBox (310, 130, 300, 160, darkgray)
Draw.FillBox (250, 125, 240, 155, darkgray)
Draw.FillBox (200, 120, 190, 150, darkgray)
Draw.FillBox (400, 120, 390, 150, darkgray)
Draw.FillBox (350, 125, 340, 180, darkgray)
Draw.FillBox (320, 125, 340, 140, gray)
Draw.FillBox (290, 125, 300, 140, gray)
Draw.FillBox (300, 125, 320, 135, darkgray)
Draw.FillBox (350, 125, 370, 150, gray)
Draw.FillBox (370, 125, 400, 140, darkgray)
Draw.FillBox (200, 124, 220, 130, gray)
Draw.FillBox (220, 125, 210, 160, gray)
Draw.FillBox (270, 125, 280, 170, darkgray)
Draw.FillBox (250, 125, 300, 135, gray)
Draw.FillBox (220, 125, 240, 135, darkgray)
Draw.FillOval (300, 350, 150, 25, gray)
Draw.FillOval (250, 370, 50, 15, darkgray)
Draw.FillOval (450, 300, 30, 10, darkgray)
Draw.FillOval (150, 280, 30, 10, darkgray)

% explosion set 4
for u : 1..10
delay (50)
Draw.FillOval (340, 180, 0+u, 0+u, brightred)
delay (50)
Draw.FillOval (235, 140, 0+u, 0+u, brightred)
delay (50)
Draw.FillOval (370, 135, 0+u, 0+u, brightred)
end for
Draw.FillBox (0,0,800,400,black)
Draw.FillOval (300,80,200,50,brown)
Draw.FillBox (0,0,800,100,blue)
Draw.FillOval (500,300,50,50,white)
Draw.FillBox (310, 130, 300, 160, darkgray)
Draw.FillBox (250, 125, 240, 155, darkgray)
Draw.FillBox (200, 120, 190, 150, darkgray)
Draw.FillBox (400, 120, 390, 150, darkgray)
Draw.FillBox (350, 125, 340, 180, darkgray)
Draw.FillBox (320, 125, 340, 140, gray)
Draw.FillBox (290, 125, 300, 140, gray)
Draw.FillBox (300, 125, 320, 135, darkgray)
Draw.FillBox (350, 125, 370, 150, gray)
Draw.FillBox (370, 125, 400, 140, darkgray)
Draw.FillBox (200, 124, 220, 130, gray)
Draw.FillBox (220, 125, 210, 160, gray)
Draw.FillBox (270, 125, 280, 170, darkgray)
Draw.FillBox (250, 125, 300, 135, gray)
Draw.FillBox (220, 125, 240, 135, darkgray)
Draw.FillOval (300, 350, 150, 25, gray)
Draw.FillOval (250, 370, 50, 15, darkgray)
Draw.FillOval (450, 300, 30, 10, darkgray)
Draw.FillOval (150, 280, 30, 10, darkgray)

%explosion set 5
for r : 1..10
delay (50)
Draw.FillOval (220, 145, 0+r, 0+r, brightred)
delay (50)
Draw.FillOval (295, 150, 0+r, 0+r, brightred)
delay (50)
Draw.FillOval (205, 130, 0+r, 0+r, brightred)
end for
Draw.FillBox (0,0,800,400,black)
Draw.FillOval (300,80,200,50,brown)
Draw.FillBox (0,0,800,100,blue)
Draw.FillOval (500,300,50,50,white)
Draw.FillBox (310, 130, 300, 160, darkgray)
Draw.FillBox (250, 125, 240, 155, darkgray)
Draw.FillBox (200, 120, 190, 150, darkgray)
Draw.FillBox (400, 120, 390, 150, darkgray)
Draw.FillBox (350, 125, 340, 180, darkgray)
Draw.FillBox (320, 125, 340, 140, gray)
Draw.FillBox (290, 125, 300, 140, gray)
Draw.FillBox (300, 125, 320, 135, darkgray)
Draw.FillBox (350, 125, 370, 150, gray)
Draw.FillBox (370, 125, 400, 140, darkgray)
Draw.FillBox (200, 124, 220, 130, gray)
Draw.FillBox (220, 125, 210, 160, gray)
Draw.FillBox (270, 125, 280, 170, darkgray)
Draw.FillBox (250, 125, 300, 135, gray)
Draw.FillBox (220, 125, 240, 135, darkgray)
Draw.FillOval (300, 350, 150, 25, gray)
Draw.FillOval (250, 370, 50, 15, darkgray)
Draw.FillOval (450, 300, 30, 10, darkgray)
Draw.FillOval (150, 280, 30, 10, darkgray)

delay (1000)

% big explosion
for x : 1 .. 900 by 10
    Draw.FillOval (325 - x, 200 + x, 75, 75, red)
    delay (10)
    Draw.FillOval (325 + x, 200 + x, 75, 75, red)
    delay (10)
    Draw.FillOval (325 + x, 200 - x, 75, 75, red)
    delay (10)
    Draw.FillOval (325 - x, 200 - x, 75, 75, red)
    Draw.FillOval (325, 200, 75 - x, 75 + x, yellow)
    delay (10)
    Draw.FillOval (325, 200, 75 + x, 75 - x, brightred)
end for

% the aftermath, basically everything redrawn without the city
Draw.FillBox (0,0,800,400,black)
Draw.FillOval (300,80,200,50,brown)
Draw.FillBox (0,0,800,100,blue)
Draw.FillOval (500,300,50,50,white)
Draw.FillOval (300, 350, 150, 25, gray)
Draw.FillOval (250, 370, 50, 15, darkgray)
Draw.FillOval (450, 300, 30, 10, darkgray)
Draw.FillOval (150, 280, 30, 10, darkgray)

Draw.Text ("The End", 300, 200, defFontID, white)


Edit by Clayton: Remember kids, [code] tags are cool!

Author:  Insectoid [ Thu Sep 25, 2008 4:42 pm ]
Post subject:  RE:Alien Attack - Animation

Instead of manually drawing each individual part, use loops and variables to make the computer do the work. It would save a LOT of lines, and makes you look smarter.

Author:  SkaarjSlayer [ Thu Sep 25, 2008 4:47 pm ]
Post subject:  Re: Alien Attack - Animation

Thanks, it was made a while ago but I'll keep that in mind the next time I program something like this.

Author:  SNIPERDUDE [ Fri Sep 26, 2008 10:15 am ]
Post subject:  RE:Alien Attack - Animation

I would of used procedures too, so you wouldn't have to reprogramme each line.

Turing:
procedure DrawCity
    Draw.FillBox (310, 130, 300, 160, darkgray)
    Draw.FillBox (250, 125, 240, 155, darkgray)
    Draw.FillBox (200, 120, 190, 150, darkgray)
    Draw.FillBox (400, 120, 390, 150, darkgray)
    Draw.FillBox (350, 125, 340, 180, darkgray)
    Draw.FillBox (320, 125, 340, 140, gray)
    Draw.FillBox (290, 125, 300, 140, gray)
    Draw.FillBox (300, 125, 320, 135, darkgray)
    Draw.FillBox (350, 125, 370, 150, gray)
    Draw.FillBox (370, 125, 400, 140, darkgray)
    Draw.FillBox (200, 124, 220, 130, gray)
    Draw.FillBox (220, 125, 210, 160, gray)
    Draw.FillBox (270, 125, 280, 170, darkgray)
    Draw.FillBox (250, 125, 300, 135, gray)
    Draw.FillBox (220, 125, 240, 135, darkgray)
end DrawCity

DrawCity
DrawWhatever
%etc...


: