
-----------------------------------
s_climax
Fri May 07, 2004 6:25 pm

Laser Wars
-----------------------------------
Read next post

-----------------------------------
s_climax
Mon May 17, 2004 9:02 pm


-----------------------------------
Here is the finished version.  The only thing it doesn't have is a good interface.

Controls for 1st player are:

up/down/left/right : move
control : shoot

For 2nd player:

w/s/a/d : move
shift : shoot

Tell me what you think.


setscreen ("nooffscreenonly")
var speed, x, y, pastx, pasty, dir, bulletx, bullety, bulletdir, bulletspeed : real
var speed2, x2, y2, pastx2, pasty2, dir2, bulletx2, bullety2, bulletdir2 : real
var chars : array char of boolean
var shoot, shoot2 : int
var gamespeed, score1, score2 : int
var pics1, pics2 : array 0 .. 359 of int
var hit : boolean
hit := false
score1 := 0
score2 := 0
gamespeed := 2
%Pic.ScreenLoad ("man.bmp", 0, 0, picMerge)
drawdot(9,11,10)
drawdot(9,12,10)
drawdot(9,17,10)
drawdot(9,18,10)
drawdot(10,11,10)
drawdot(10,12,10)
drawdot(10,17,10)
drawdot(10,18,10)
drawfillbox(11,11,12,18,10)
drawfillbox(13,11,16,12,20)
drawfillbox(13,17,16,18,20)
drawfillbox(16,13,17,16,20)
drawfillbox(13,13,16,16,110)
drawfillbox(13,10,16,7,40)
drawfillbox(13,18,16,20,40)
drawfillbox(13,21,18,22,68)
drawfillbox(13,5,18,6,68)
drawfillbox(19,5,22,6,7)
drawfillbox(23,7,28,8,7)
pics1 (0) := Pic.New (0, 0, 28, 28)
cls
for angle : 1 .. 359
    drawbox (maxx div 2 - 180, maxy div 2 - 50, maxx div 2 + 180, maxy div 2 + 50, 7)
    drawfillbox (maxx div 2 - 180, maxy div 2 - 50, maxx div 2 - 180 + (angle div 2), maxy div 2 + 50, 7)
    %locate (3, 3)
    %put "Creating picture rotated ", angle, " degrees"
    pics1 (angle) := Pic.Rotate (pics1 (0), angle, 14, 14)
end for
%Pic.ScreenLoad ("man2.bmp", 0, 0, picMerge)
drawdot(9,11,6)
drawdot(9,12,6)
drawdot(9,17,6)
drawdot(9,18,6)
drawdot(10,11,6)
drawdot(10,12,6)
drawdot(10,17,6)
drawdot(10,18,6)
drawfillbox(11,11,12,18,6)
drawfillbox(13,11,16,12,42)
drawfillbox(13,17,16,18,42)
drawfillbox(16,13,17,16,42)
drawfillbox(13,13,16,16,110)
drawfillbox(13,10,16,7,56)
drawfillbox(13,18,16,20,56)
drawfillbox(13,21,18,22,68)
drawfillbox(13,5,18,6,68)
drawfillbox(19,5,22,6,7)
drawfillbox(23,7,28,8,7)
pics2 (0) := Pic.New (0, 0, 28, 28)
cls
for angle : 1 .. 359
    %locate (3, 3)
    drawbox (maxx div 2 - 180, maxy div 2 - 50, maxx div 2 + 180, maxy div 2 + 50, 7)
    drawfillbox (maxx div 2 - 180, maxy div 2 - 50, maxx div 2 + (angle div 2), maxy div 2 + 50, 7)
    %put "Creating picture rotated ", angle, " degrees"
    pics2 (angle) := Pic.Rotate (pics2 (0), angle, 14, 14)
end for
cls
setscreen ("offscreenonly;nocursor")
loop
    put "You are playing a game up to ", (50 * (6 - gamespeed)), " points."
    put "Press any key to continue"
    View.Update
    cls
    exit when hasch
end loop
speed := 1 * gamespeed
bulletspeed := 20 * gamespeed
dir := 180
x := maxx div 2 - 50
y := maxy div 2
shoot := 0
speed2 := 1 * gamespeed
dir2 := 0
x2 := maxx div 2 + 50
y2 := maxy div 2
shoot2 := 0
loop
    shoot := 0
    shoot2 := 0
    loop
        pastx := x
        pasty := y
        pastx2 := x2
        pasty2 := y2
        %1st Player Controls
        Input.KeyDown (chars)
        if chars (KEY_UP_ARROW) then
            x += cosd (dir) * speed
            y += sind (dir) * speed
        end if
        if chars (KEY_DOWN_ARROW) then
            x += cosd (dir) * -speed
            y += sind (dir) * -speed
        end if
        if chars (KEY_LEFT_ARROW) then
            dir += speed
        end if
        if chars (KEY_RIGHT_ARROW) then
            dir -= speed
        end if
        if chars (KEY_CTRL) then
            shoot := 1
        end if
        %2nd Player Controls
        if chars ('w') then
            x2 += cosd (dir2) * speed2
            y2 += sind (dir2) * speed2
        end if
        if chars ('s') then
            x2 += cosd (dir2) * -speed2
            y2 += sind (dir2) * -speed2
        end if
        if chars ('a') then
            dir2 += speed2
        end if
        if chars ('d') then
            dir2 -= speed2
        end if
        if chars (KEY_SHIFT) then
            shoot2 := 1
        end if
        %1st Player Bullet
        if shoot = 1 then
            bulletx += cosd (bulletdir) * bulletspeed
            bullety += sind (bulletdir) * bulletspeed
        else
            bulletx := x + cosd (dir - 40) * 10
            bullety := y + sind (dir - 40) * 10
            bulletdir := dir
        end if
        if bulletx > 0 or bulletx < maxx or bullety > 0 or bullety < maxy then
            shoot := 0
        end if
        %2nd Player Bullet
        if shoot2 = 1 then
            bulletx2 += cosd (bulletdir2) * bulletspeed
            bullety2 += sind (bulletdir2) * bulletspeed
        else
            bulletx2 := x2 + cosd (dir2 - 40) * 10
            bullety2 := y2 + sind (dir2 - 40) * 10
            bulletdir2 := dir2
        end if
        if bulletx2 > 0 or bulletx2 < maxx or bullety2 > 0 or bullety2 < maxy then
            shoot2 := 0
        end if
        if x = maxx - 20 or y = maxy - 30 then
            x := pastx
            y := pasty
        end if
        if x2 = maxx - 20 or y = maxy - 30 then
            x2 := pastx2
            y2 := pasty2
        end if
        if round (sqrt ((x2 - x) ** 2 + (y2 - y) ** 2)) < 35 then
            x := pastx
            y := pasty
            x2 := pastx2
            y2 := pasty2
        end if
        if dir = 359 then
            dir -= 359
        end if
        if dir2 = 359 then
            dir2 -= 359
        end if
        delay (0)
        cls
        Pic.Draw (pics1 (round (dir)), round (x) - 14, round (y) - 14, picMerge)
        Pic.Draw (pics2 (round (dir2)), round (x2) - 14, round (y2) - 14, picMerge)
        drawdot (round (bulletx), round (bullety), black)
        drawdot (round (bulletx2), round (bullety2), black)
        drawline (round (x + cosd (dir - 40) * 10), round (y + sind (dir - 40) * 10), round (bulletx), round (bullety), brightred)
        drawline (round (x2 + cosd (dir2 - 40) * 10), round (y2 + sind (dir2 - 40) * 10), round (bulletx2), round (bullety2), brightred)
        drawfillbox (0, maxy, maxx, maxy - 30, 7)
        %drawline(0,maxy,
        locatexy (0, maxy)
        put score1
        if score2 < 100 then
            locatexy (maxx - 10, maxy)
        else
            locatexy (maxx - 20, maxy)
        end if
        put score2
        Pic.ScreenLoad ("man.bmp", 30, maxy - 30, picMerge)
        Pic.ScreenLoad ("man2.bmp", maxx - 60, maxy - 30, picMerge)
        View.Update
        if round (sqrt ((bulletx - x2) ** 2 + (bullety - y2) ** 2)) < 20 then
            hit := true
            shoot := 0
            score1 += 1
        end if
        if round (sqrt ((bulletx2 - x) ** 2 + (bullety2 - y) ** 2)) < 20 then
            hit := true
            shoot2 := 0
            score2 += 1
        end if
        exit when score1 > (50 * (6 - gamespeed)) or score2 > (5 * (6 - gamespeed)) or hit = true
    end loop
    exit when score1 > (50 * (6 - gamespeed)) or score2 > (5 * (6 - gamespeed))
end loop
if score1 > score2 then
    locatexy (maxx div 2, maxy div 2)
    put "Player 1 Wins"
else
    locatexy (maxx div 2, maxy div 2)
    put "Player 2 Wins"
end if


-----------------------------------
guruguru
Mon May 17, 2004 9:22 pm


-----------------------------------
:?:  Where is it  :?:  Wow... there seem to be more and more files that people say to try that simply are not there...  :cry:

-----------------------------------
netninja
Tue May 18, 2004 6:49 am


-----------------------------------
Not bad, but its way too hard to hit the enemy, the keyboards too sensitive. And the movements a bit too fast. Also, you should tell us the controls before  gameplay so people know what to do, maybe make some obstacles on course. And last, but very important. When you hold the laser and you turn around, it shoots the the same spot as where it originally was, kinda weird. For your next game it would be fun if you made a paintball game, and you could play over internet or lan or w/e.

Nice though, good example of key movement.

-----------------------------------
Mazer
Tue May 18, 2004 6:49 am


-----------------------------------
Holding down the fire button while aimed directly at someone only gives you one point. If you're going to force the player to fire single shots for points, at least make the fire button shoot a single beam instead of a continuous one so they know that. Er, know what I mean?

Also, if you shoot in one direction and hold down the fire button, if you turn he'll still be shooting in the original direction.

Still, kinda neat.

-----------------------------------
Paul
Tue May 18, 2004 4:07 pm


-----------------------------------
Hm... whenever I run this, it crashes my  turing, maybe because I don't have the picture files?

-----------------------------------
s_climax
Tue May 18, 2004 4:09 pm


-----------------------------------
The picture files are commented.  That should not be why.

-----------------------------------
Paul
Tue May 18, 2004 4:24 pm


-----------------------------------
Well, I can get to the loading bar, but just when its about to finish, it goes "the environment (not your program) has crashed" etc with a bunch of technical stuff.

-----------------------------------
AsianSensation
Tue May 18, 2004 5:08 pm


-----------------------------------
Omg! Red railguns.....

lol, +5 bits to this neat program.

-----------------------------------
Viper
Wed Nov 17, 2004 9:16 am

little guys
-----------------------------------
the one guy can runn right oss screen n gets lost  and i agree with that othr guy you should make the shooting single not umm.... continuos ray

-----------------------------------
zomg
Wed Nov 17, 2004 12:06 pm


-----------------------------------
LOL NICE PROGRAM I LOVE THIS THING 

Great job(so basic yet so fun)

-----------------------------------
m&amp;m
Wed Nov 17, 2004 4:09 pm


-----------------------------------
cool game.  this is fun thanks nice work

-----------------------------------
MattyGG
Mon Nov 22, 2004 11:37 am


-----------------------------------
I think its pretty good, and fun...kinda hard to aim the shots right, and i think that you should get more points for a shot if its up to 200...but other than that, i really like it

-----------------------------------
Viper
Mon Nov 22, 2004 1:03 pm


-----------------------------------
it would be kool if more poeple could play like have it ask how many players n have it go up 2 like 4 people

-----------------------------------
Carino
Mon Nov 22, 2004 3:53 pm


-----------------------------------
Cool prog, add some obstacles that will stop the lasers/men so it adds a more strategic affect to it, but altogether its good.

-----------------------------------
Cervantes
Mon Nov 22, 2004 4:13 pm


-----------------------------------
For your next game it would be fun if you made a paintball game

[url=http://www.compsci.ca/v2/viewtopic.php?t=6723]Flexible Arrays will become your best friend when making a paintball game.
(but then you'll learn to hate them because you can't use them in with types)

-----------------------------------
zomg
Tue Nov 23, 2004 12:10 pm


-----------------------------------
making the laser spin with the guy would be good  :)

-----------------------------------
Viper
Tue Nov 23, 2004 1:56 pm


-----------------------------------
like dat other guy said u should add some obstacles to add more strategy
n you should make it shoot a ray of radius 1,1 ovals bc then you could hold it in stead of havin to repededly press it[/quote]

-----------------------------------
m&amp;m
Wed Nov 24, 2004 12:05 pm


-----------------------------------
making obstacles and playing against the computer would be fun :)

and if u do that u got make different characters to select and each guy has his str and weaknesses

-----------------------------------
BPhelmet
Wed Dec 15, 2004 9:47 pm


-----------------------------------
pretty cool, but just the people move too fast

-----------------------------------
ste_louis26
Tue Jan 25, 2005 1:21 pm


-----------------------------------
Good game> Could add different guns with health that depletes after each attack

-----------------------------------
Pip_Jr
Tue Feb 15, 2005 12:59 pm


-----------------------------------
That....was....AWSOME :shock: !!! I had fun just flying arround!  While my friend was reading something you guys put about matrix being real or not being real... then it turned to a fight about reality... ANYWAYS! i crashed a couple of times..... but you don't know that couse I'm not real... wait oh no! *Fades away*
