#!/usr/bin/perl use POSIX qw(ceil floor); #Drew clinkenbeard hack job scorched earth #p1 and p2 are arrays #0 = player name #1 = health #2 = range from zero negative for p1 pos for p2 system ('clear'); print "welcome to drews 1337 h4xx0r Scorched Earth prog\n from dream to reality in 2 hours, with nothin but mustard.\n\n\n"; print "Player 1 who are you?\n My name is: "; $_ = ; chomp; @p1[0] = $_; print "\nWho would challenge $p1[0]?\nEnter your name: "; $_ = ; chomp; @p2[0]=$_ ; print "\n Welcome $p1[0] and $p2[0] to the glorious arena!"; print "\nsome of you will live, some of you wont be so lucky."; print "\nthe rules are simple, the arena is 100 ADU long you're both in it."; print "\nYou must launch your weapon by inputing an angle and a velocity"; print "\nthe first to hit the other three times wins!\n"; print "\nMAY GOD HAVE MERCY ON YOUR SOULS!\n\n"; @p1[1] = 3; @p2[1] = 3; $range = 50; @p1[2] = int(rand($range)) - $range; # give a value betweent -1 and -50 @p2[2] = int(rand($range)) + 1; #determine the range between them $_ = @p1[2]*-1; $range = $_ +@p2[2]; #comment this out for play print "\n@p1[0] is at @p1[2], @p2[0] is at @p2[2]\n"; print "they are $range arbitrary distance units appart\n"; print "@p1[0] health = @p1[1] , @p2[0] health = @p2[1]\n"; $minHealth =4 ; while (@p1[1] > 0 && @p2[1] > 0) { print "@p1[0] enter your angle!: "; $_ = ; chomp; $theta = $_*(0.017453292519943295769236907684886/180); print "\nnow @p1[0] what velocity? : "; $_ = ; chomp; $v0 = $_; $hit = &impact(@p1[0], @p2[0], $range, $v0, $theta); if(@p1[0] eq "Samalander"){ print "\nthe Samalander is here!\n"; $hit =1; } if($hit){ print "@p1[0] brutaly hits @p2[0]!! oh the humanity!\n"; @p2[1] = @p2[1]-1; print "\n@p2[0] health now = @p2[1]\n"; }else{ print "\nWHIFF! @p1[0] misses!\n"; } if(@p2[1] <= 0){ last; } print "@p2[0] enter your angle!: "; $_ = ; chomp; $theta = $_*(0.017453292519943295769236907684886/180); print "\nnow @p2[0] what velocity? : "; $_ = ; chomp; $v0 = $_; $hit =&impact(@p2[0], @p1[0], $range, $v0, $theta); if(@p2[0] eq "Samalander"){ $hit = 1; } if($hit){ print "@p2[0] brutaly hits @p1[0]!! oh the humanity!\n"; @p1[1] = @p1[1] -1; print "\n@p1[0] health = @p1[1]\n"; }else{ print "\nWHIFF! @p2[0] misses!\n"; } } if (@p1[1] > 0){ print "\n@p1[0] Stands victorious! @p2[0] lost! HA! you STINK @p2[0]!!!\n"; }else{ print "\n@p2[0] Stands victorious! @p1[0] lost! HA! you STINK @p1[0]!!!\n"; } sub get_angVel { my $player = $_[0]; my $theta = 0; my $v = 0; print "$player enter your angle!: "; $_ = ; chomp; $theta = $_*(0.017453292519943295769236907684886/180); print "\nnow $player what velocity? : "; $_ = ; chomp; $v = $_; return ($v, $theta); } sub impact { my $shooter = $_[0]; my $shot = $_[1]; my $range = $_[2]; my $v = $_[3]; my $angle =$_[4]; my $x1 =0; my $t=0.5; my $y1=1; my $g = -4.905; my $foo = 0; #print "\nv = $v angle = $angle\n"; #print "\n range = $range x1 = $x1\n"; while ($y1 >= 0){ #print "\n y = $y1\n"; $foo =($v*cos($theta)); $foo = $t*$foo; $x1 = $foo+$x1; $x1 = floor($x1); #print "\n foo = $foo\n"; $foo =($v*sin($theta)); #print "\n foo = $foo\n"; $y1 = $y1+$foo; #print "\n y = $y1\n"; $y1 = $y1*$t; #print "\n y = $y1\n"; $y1 = $y1+($g*($t*$t)); #print "\n y = $y1\n"; $y1 = floor($y1); #print "\n x1 = $x1 y1 = $y1\n"; $t = $t+$t; } print "\n $shooter shot landed at $x1\n"; #print "\n range = $range and x1 = $x1\n"; #print "\n y at end = $y1\n"; if($x1 == $range){ return 1; }else{ return 0; } }