Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Help with destroying astroids
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
vagyb




PostPosted: Sat Jun 04, 2005 9:46 pm   Post subject: Help with destroying astroids

edited: need some feedback on what i can improve

new attachment



game.rar
 Description:

Download
 Filename:  game.rar
 Filesize:  122.76 KB
 Downloaded:  116 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
McKenzie




PostPosted: Sun Jun 05, 2005 12:36 am   Post subject: Re: Help with destroying astroids

vagyb wrote:
if bulletx + bulletHeight >= boulder1X - 1 and bulletx <= boulder1X + 1 and bullety + shipHeight / 2 > boulder1Y and bullety + bulletHeight / 2 < boulder1Y + boulderHeight then

should be:
code:
if bulletx + bulletHeight >= boulder1X - 1 and bulletx <= boulder2X + 1 and bullety + shipHeight / 2 > boulder1Y and bullety < boulder1Y + boulderHeight then

I've made some assumptions about your variables.
vagyb




PostPosted: Sun Jun 05, 2005 5:47 am   Post subject: (No subject)

thx for pointing that out i fixed it but still it does not look like its working. Where do i have to put this detection of bullets? inside the loop of astroids?
vagyb




PostPosted: Tue Jun 07, 2005 1:11 pm   Post subject: (No subject)

yep
jamonathin




PostPosted: Tue Jun 07, 2005 1:41 pm   Post subject: (No subject)

See? God helps those who help themselves.
vagyb




PostPosted: Wed Jun 08, 2005 12:06 pm   Post subject: (No subject)

what if u dont believe in god?
vagyb




PostPosted: Wed Jun 08, 2005 1:39 pm   Post subject: (No subject)

i think i fixed it Smile i used whatdotcolor command instead and it seems to be working

code:

%Vagharshak Bakhshyan
%Mr. Blea
%Computer ISU
setscreen ("graphics:700;530,position:middle;centre,nobuttonbar,title:Space,nocursor, offscreenonly") %setting the screen with the desired parameters, features
var ch : string (1)
var choosebullet : int
var t1, t2, tt : int %variables
var font1 : int
var font2 : int
var font3 : int
var font4 : int
var datafile : int
var rule : string
font1 := Font.New ("Timesnewroman:25") %giving value to the variables of the fonts
font2 := Font.New ("Timesnewroman:15")
font3 := Font.New ("Timesnewroman:22")
font4 := Font.New ("verdana:10")
const margin : int := 10 % giving the margin a constant value
var boulderexplode : int
var position1 : int
var position2 : int
var position3 : int
var position4 : int
var position5 : int
var position6 : int
var heart : int
var heart2 : int
var heart3 : int
var heartWidth : int
var heartHeight : int
var heartA : int := 575
var heartB : int := 1
var heartC : int := 605
var heartD : int := 1
var heartE : int := 635
var heartF : int := 1
var heartG : int := 665
var heartH : int := 1
var heart3A : int := 695
var heart3B : int := 1
var shipPic : int
var ship2Pic : int
var boulderPic : int
var boulder2Pic : int
var boulder3Pic : int
var boulder4Pic : int
var boulder5Pic : int
var boulder6Pic : int
var boulderWidth : int   %the width of the boulder picture
var boulderHeight : int
var boulder2Width : int
var boulder2Height : int
var boulder3Width : int
var boulder3Height : int
var boulder4Width : int
var boulder4Height : int
var boulder5Width : int
var boulder5Height : int
var boulder6Width : int
var boulder6Height : int
var shipX, shipY : int

var shipWidth, shipHeight : int
var chars : array char of boolean %used for key movement (makes the ship go up and down)
var speed : int := 1
var bulletWidth : int
var bulletHeight : int

heart := Pic.FileNew ("heart.bmp")
heart2 := Pic.FileNew ("heart2.bmp")
heart3 := Pic.FileNew ("heart3.bmp")
boulderexplode := Pic.FileNew ("boulderexplode.bmp")
shipPic := Pic.FileNew ("ship.bmp") %loading the pictures
boulderPic := Pic.FileNew ("boulder.bmp")
boulder2Pic := Pic.FileNew ("boulder2.bmp")
boulder3Pic := Pic.FileNew ("boulder3.bmp")
boulder4Pic := Pic.FileNew ("boulder4.bmp")
boulder5Pic := Pic.FileNew ("boulder5.bmp")
boulder6Pic := Pic.FileNew ("boulder6.bmp")
ship2Pic := Pic.FileNew ("ship2.bmp")
%bullet := Pic.FileNew ("bullet.bmp")
shipWidth := Pic.Width (shipPic) %giving value to the pictures
shipHeight := Pic.Height (shipPic)
boulderHeight := Pic.Height (boulderPic)
boulderWidth := Pic.Width (boulderPic)
boulder2Height := Pic.Height (boulder2Pic)
boulder2Width := Pic.Width (boulder2Pic)
boulder3Height := Pic.Height (boulder3Pic)
boulder3Width := Pic.Width (boulder3Pic)
boulder4Height := Pic.Height (boulder4Pic)
boulder4Width := Pic.Width (boulder4Pic)
boulder5Height := Pic.Height (boulder5Pic)
boulder5Width := Pic.Width (boulder5Pic)
boulder6Height := Pic.Height (boulder6Pic)
boulder6Width := Pic.Width (boulder6Pic)

shipX := 0                  % Ship is on left hand side of screen so it is set at 0 (the farthest left)
shipY := maxy div 2         % Original Y is set to be half the screen height
var boulder1X : int := 450 %giving the X location of the border when they enter the screen the first time
var boulder1Y : int := 30 % giving the Y location
var boulder2X : int := 500
var boulder2Y : int := 180
var boulder3X : int := 280
var boulder3Y : int := 320
var boulder4X : int := 430
var boulder4Y : int := 250
var boulder5X : int := 500
var boulder5Y : int := 300
var boulder6X : int := 350
var boulder6Y : int := 80
var bulletx, bullety : int := 0
var isShooting : boolean := false
var liveslost : int := 0
var ts1, ts2 : int
var laserbullet : int := Pic.FileNew ("laserbullet.bmp")
var mainautobullet : int := Pic.FileNew ("mainautobullet.bmp")
var autobullet : int := Pic.FileNew ("autobullet.bmp")
var choice : string (1)

laserbullet := Pic.FileNew ("laserbullet.bmp")
%open : datafile, "data.t", get %opens datafile to read the rules of the game
%delay (1000)
%drawfillbox (1, maxy, maxx, 1, 78)
%loop
%   colorback (78)
% locate (5, 1)
% color (blue)
% get : datafile, skip
% exit when eof (datafile)
%  get : datafile, rule : *
%   put rule
%end loop

%Font.Draw ("Rules", 185, 320, font3, 40)
%Font.Draw ("Created by: Vagharshak Bakhshyan", 100, 200, font4, 40) %Writes specific text with specific font
drawfillbox (1, 1, maxx, maxy, black)
Font.Draw ("SELECT YOUR WEOPON", 170, 470, font1, 72)
Pic.Draw (laserbullet, 10, 320, picCopy)
Pic.Draw (mainautobullet, 8, 220, picCopy)

%Input.KeyDown (choice)
var bullet : int
getch (choice)
if choice = "1" then
    bullet := Pic.FileNew ("bullet.bmp")
    bulletWidth := Pic.Width (bullet) %giving value to the pictures
    bulletHeight := Pic.Height (bullet)
else
    bullet := Pic.FileNew ("autobullet.bmp")
    bulletWidth := Pic.Width (bullet)   %giving value to the pictures
    bulletHeight := Pic.Height (bullet)
end if




color (22)
locate (12, 13)
%put "Press any key to start the game"
getch (ch)

procedure drawHearts
    Pic.Draw (heart, heartA, heartB, picMerge)
    Pic.Draw (heart, heartC, heartD, picMerge)
    Pic.Draw (heart, heartE, heartF, picMerge)
    Pic.Draw (heart, heartG, heartH, picMerge)
    case liveslost of
        label 1 :
            Pic.Draw (heart3, heartG, heartH, picMerge)
        label 2 :
            Pic.Draw (heart3, heartG, heartH, picMerge)
            Pic.Draw (heart3, heartE, heartF, picMerge)
        label 3 :
            Pic.Draw (heart3, heartG, heartH, picMerge)
            Pic.Draw (heart3, heartE, heartF, picMerge)
            Pic.Draw (heart3, heartC, heartD, picMerge)
        label 4 :
            Pic.Draw (heart3, heartG, heartH, picMerge)
            Pic.Draw (heart3, heartE, heartF, picMerge)
            Pic.Draw (heart3, heartC, heartD, picMerge)
            Pic.Draw (heart3, heartA, heartB, picMerge)
            %Pic.Draw (ship2Pic, shipX, shipY, picMerge)


            locate (19, 38)
            color (78)
            %put tt .. %puts how much time passed
            color (white)
            Font.Draw ("You Lose", 150, 160, font1, 72)
            locate (18, 20)
            color (white)
            Font.Draw ("The total score is ", 140, 50, font2, 78)
        label :
    end case
end drawHearts

procedure mainGame
    loop
        Input.KeyDown (chars)
        if chars (KEY_UP_ARROW) then     %makes the ship go up and down
            shipY += 2
        elsif chars (KEY_DOWN_ARROW) then
            shipY -= 2
            % wallclock (t1) %start of the timer
        elsif chars (' ') then
            isShooting := true
            bullety := shipY + 20
            bulletx := shipX + 95
            %exit

        end if

        if chars ('s') or chars ('S') then
            speed := 2
        else
            speed := 1
        end if

        %wallclock (t2)            %end of the timer
        %tt := t2 - t1
        if isShooting then
            bulletx += 10
            %  wallclock (ts2)
            if bulletx > 670 and isShooting = true then
                bulletx := -23
                bullety := 0
                isShooting := false
                % elsif ts2 - ts1 > 2 and isShooting = true then
                %  isShooting := false
                %else
                %    isShooting := true
            end if
        end if

        if whatdotcolor (bulletx + 30, bullety) not= black then
            sound (400, 50)
        end if



        if boulder1X + boulderWidth <= 0 then
            boulder1X := maxx
            randint (boulder1Y, 1, maxy)     %makes the placement of the astroids random after the first time they come
        else
            boulder1X -= 1 * speed     %speed of the astroids

        end if

        if boulder2X + boulder2Width <= 0 then
            boulder2X := maxx
            randint (boulder2Y, 1, maxy)
        else
            boulder2X -= 2 * speed
        end if

        if boulder3X + boulder3Width <= 0 then
            boulder3X := maxx
            randint (boulder3Y, 1, maxy)
        else
            boulder3X -= 2 * speed

        end if

        if boulder4X + boulder4Width <= 0 then
            boulder4X := maxx
            randint (boulder4Y, 1, maxy)
        else
            boulder4X -= 2 * speed
        end if

        if boulder5X + boulder5Width <= 0 then
            boulder5X := maxx
            randint (boulder5Y, 1, maxy)
        else
            boulder5X -= 1 * speed
        end if
        if boulder6X + boulder6Width <= 0 then
            boulder6X := maxx
            randint (boulder6Y, 1, maxy)
        else
            boulder6X -= 3 * speed

        end if

        if shipY <= 0 then                  % If the ship is below 0 (bottom of screen)
            shipY := 0                    % make ship y = 0
        elsif shipY + shipHeight >= maxy then     % If the ship is above maxy (top of screen)
            shipY := maxy - shipHeight      % make ship y equal to top of screen - height of ship
        end if
        colorback (black)
        cls
        drawHearts

        Pic.Draw (boulderPic, boulder1X, boulder1Y, picMerge)     %draws the specified picture
        Pic.Draw (boulder2Pic, boulder2X, boulder2Y, picMerge)
        Pic.Draw (boulder3Pic, boulder3X, boulder3Y, picMerge)
        Pic.Draw (boulder4Pic, boulder4X, boulder4Y, picMerge)
        Pic.Draw (boulder5Pic, boulder5X, boulder5Y, picMerge)
        Pic.Draw (boulder6Pic, boulder6X, boulder6Y, picMerge)
        Pic.Draw (shipPic, shipX, shipY, picMerge)
        Pic.Draw (bullet, bulletx, bullety, picMerge)

        View.Update

        if shipX + shipWidth >= boulder1X - 5 and shipX <= boulder1X + 5 and shipY + shipHeight / 2 > boulder1Y and shipY + shipHeight / 2 < boulder1Y + boulderHeight
            %checks if the ship collides with the boulders
                or shipX + shipWidth >= boulder2X - 5 and shipX <= boulder2X + 5 and shipY + shipHeight / 2 > boulder2Y and shipY + shipHeight / 2 < boulder2Y + boulder2Height
                or shipX + shipWidth >= boulder3X - 5 and shipX <= boulder3X + 5 and shipY + shipHeight / 2 > boulder3Y and shipY + shipHeight / 2 < boulder3Y + boulder3Height
                or shipX + shipWidth >= boulder4X - 5 and shipX <= boulder4X + 5 and shipY + shipHeight / 2 > boulder4Y and shipY + shipHeight / 2 < boulder4Y + boulder4Height
                or shipX + shipWidth >= boulder5X - 5 and shipX <= boulder5X + 5 and shipY + shipHeight / 2 > boulder5Y and shipY + shipHeight / 2 < boulder5Y + boulder5Height
                or shipX + shipWidth >= boulder6X - 5 and shipX <= boulder6X + 5 and shipY + shipHeight / 2 > boulder6Y and shipY + shipHeight / 2 < boulder6Y + boulder6Height then
            Pic.Draw (ship2Pic, shipX, shipY, picMerge)
            liveslost += 1
            put liveslost
            drawHearts
            exit     %exit
        end if
    end loop      %end loop
end mainGame


proc crash
    if bulletx + bulletHeight >= boulder1X - 1 and bulletx <= boulder2X + 1 and bullety + shipHeight / 2 > boulder1Y and bullety < boulder1Y + boulderHeight then
        Pic.Draw (boulderexplode, boulder1X, boulder1Y, picMerge)
    elsif bulletx + bulletWidth >= boulder2X - 1 and bulletx <= boulder2X + 1 and bullety + shipHeight / 2 > boulder2Y and bullety < boulder1Y + boulder2Height then
        Pic.Draw (boulderexplode, boulder2X, boulder2Y, picMerge)
    elsif bulletx + bulletWidth >= boulder3X - 1 and bulletx <= boulder3X + 1 and bullety + shipHeight / 2 > boulder3Y and bullety < bulletHeight + boulder3Height then
        Pic.Draw (boulderexplode, boulder3X, boulder3Y, picMerge)
    elsif bulletx + bulletWidth >= boulder4X - 1 and bulletx <= boulder4X + 1 and bullety + shipHeight / 2 > boulder4Y and bullety < bulletHeight + boulder4Height then
        Pic.Draw (boulderexplode, boulder4X, boulder4Y, picMerge)
    elsif bulletx + bulletWidth >= boulder5X - 1 and bulletx <= boulder5X + 1 and bullety + shipHeight / 2 > boulder5Y and bullety < bulletHeight + boulder5Height then
        Pic.Draw (boulderexplode, boulder5X, boulder5Y, picMerge)
    elsif bulletx + bulletWidth >= boulder6X - 1 and bulletx <= boulder6X + 1 and bullety + shipHeight / 2 > boulder6Y and bullety < bulletHeight + boulder6Height then
        Pic.Draw (boulderexplode, boulder6X, boulder6Y, picMerge)
    end if
end crash

loop

    mainGame
    %  crash
    delay (200)

    shipX := 0                  % Ship is on left hand side of screen so it is set at 0 (the farthest left)
    shipY := maxy div 2     % Original Y is set to be half the screen height

    randint (position1, 200, maxx)
    randint (position2, 250, maxx)
    randint (position3, 100, maxx)
    randint (position4, 150, maxx)
    randint (position5, 150, maxx)
    randint (position6, 300, maxx)


    boulder1X := position1
    boulder1Y := position2
    boulder2X := position3
    boulder2Y := position4
    boulder3X := position5
    boulder3Y := position1
    boulder4X := position3
    boulder4Y := position5
    boulder5X := position4
    boulder5Y := position6
    boulder6X := position1
    boulder6Y := position4

    if liveslost > 3 then

        exit
    end if

end loop

vagyb




PostPosted: Wed Jun 08, 2005 9:01 pm   Post subject: (No subject)

okay well i fixed up almost everything, some feedback would be appreciated


game.rar
 Description:

Download
 Filename:  game.rar
 Filesize:  122.76 KB
 Downloaded:  114 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Drakain Zeil




PostPosted: Wed Jun 08, 2005 9:48 pm   Post subject: (No subject)

I'd check it but a) I'm need to install unrar to unrar it, 2) I'd need to go over to windows, 3) I'd need to install turring again.

So if you can hold on for three weeks then yeah I'll check it out and give you all the advice I can.

jamonathin wrote:
See? God helps those who help themselves.
That's like saying "Don't bug me."
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 9 Posts ]
Jump to:   


Style:  
Search: