Computer Science Canada

Helicopter Game Help

Author:  Conrad13 [ Thu Dec 15, 2011 8:07 pm ]
Post subject:  Helicopter Game Help

I'm sure everyone here has played the infamous Helicopter game where you simply click the screen to increase elevation and let go to decrease.
Okay, so I am trying to make a helicopter game, I have the intro done but i need a lot of help making the environment that is passes through and so on. I also am looking to making a separate page for controls which you can view before selecting to play the game.
Keeping in mind i will want it to be as realistic as possible like I want the distance to be counting in the corner of the screen and so on.
I need to make it so that when the colours of the helicopter contact the colours of the environment, then it ends the game and says replay, I am not new to Turing so I will for the better part know what you guys are trying to say however don't make it to complex.

This is what I have so far.







Turing:

var icolor : int
var icolor2 : int
var iXposition : int
var iYposition : int
var xdirection : int
var ydirection : int
var font : int
var font1 : int
var font2 : int
font := Font.New ("serif:50")
font1 := Font.New ("serif:20")
font2 := Font.New ("serif:20")

icolor2 := 21
icolor := 1
iXposition := 0
iYposition := 80
xdirection := 1
ydirection := 1
View.Set ("graphics,offscreenonly")
loop
    Draw.Cls


    % Background
    drawfillbox (0, 0, maxx, maxy, 100)


    % Cloud 1
    drawfilloval (90, 350, 130, 80, white)
    drawfilloval (70, 280, 80, 40, white)
    drawfilloval (200, 310, 60, 50, white)
    drawfilloval (230, 380, 60, 50, white)

    % Cloud 2
    drawfilloval (400, 150, 130, 80, white)
    drawfilloval (380, 80, 80, 40, white)
    drawfilloval (410, 220, 80, 40, white)
    drawfilloval (520, 110, 70, 50, white)
    drawfilloval (520, 190, 80, 50, white)
    drawfilloval (300, 180, 60, 50, white)
    drawfilloval (300, 120, 40, 30, white)


    % Helicopter
    drawfillbox (iXposition + 85, iYposition + 5, iXposition + 155, iYposition + 10, black) % Base (legs)
    drawfillbox (iXposition + 100, iYposition + 10, iXposition + 105, iYposition + 20, black) % Base 1
    drawfillbox (iXposition + 135, iYposition + 10, iXposition + 140, iYposition + 20, black) % Base 2
    drawfillbox (iXposition + 118, iYposition + 80, iXposition + 123, iYposition + 65, black) % Main Rotor
    drawfillbox (iXposition + 25, iYposition + 40, iXposition + 130, iYposition + 50, black) % Rotor rectangle
    drawfilloval (iXposition + 120, iYposition + 85, 70, 5, icolor2) % Rotor Blades
    drawfilloval (iXposition + 120, iYposition + 45, 40, 30, black) % Cockpit
    drawfillbox (iXposition + 10, iYposition + 40, iXposition + 15, iYposition + 70, black) % Rotor rectangle
    drawfilloval (iXposition + 15, iYposition + 48, 15, 15, icolor2) % Rear Rotor
    drawfilloval (iXposition + 85, iYposition + 45, 20, 15, black) % Smaller circle from main body of helicopter




    Draw.Text ("Super-Heli", 190, 25, font, icolor - 1)
    Draw.Text ("Play", 300, 240, font1, icolor - 1)
    Draw.Text ("Controls", 280, 200, font2, icolor - 1)
    icolor := icolor + 1
    if icolor = 62 then
        icolor := 1
    end if
    icolor2 := icolor2 + 1
    if icolor2 = 31 then
        icolor2 := 21
    end if
    iXposition := iXposition + xdirection
    iYposition := iYposition + ydirection

    if iXposition > 445 or iXposition < 0 then
        xdirection := -xdirection
    end if

    if iYposition > 305 or iYposition < 80 then
        ydirection := -ydirection
    end if

    delay (1)
    View.Update
end loop


Using Turing 4.1.1

Author:  Aange10 [ Thu Dec 15, 2011 8:48 pm ]
Post subject:  RE:Helicopter Game Help

I can't even read your post, my eyes hurt. Don't post in all bold!!

I'm not sure I can infer your problem, considering I could barley comprehend your giant wall of dark text. If you did state your problem, I missed it.

Where do you need help? Specifically? and what have YOU tried to fix it?


EDIT: I think in a lucky glance at that cannon up there, I have found your problem (?).

Quote:

I need to make it so that when the colours of the helicopter contact the colours of the environment, then it ends the game


code:

loop
if helicopter.color = helicopter.contractColor then
  endGame := true
end if
exit when endGame = true
end loop

Author:  Conrad13 [ Thu Dec 15, 2011 9:42 pm ]
Post subject:  Re: Helicopter Game Help

Well, I have more then a simple problem, and sorry for the text as this is my first post I didnt know what to do. But anyways basically these are my problems:
- Creating a Menu where you click on the Controls or the Play and it takes you to either controls or play.( I created that intro part seen above however i do not know how to get it so that when you click it brings you to the controls or enters the game.
- Then I need to basically create the game (Helicopter controls (arrow keys or mouse click), environment to which it must dodge something i do not know what yet(hopefully more then shapes).
- Then the part where it measures (in the corner of the screen) the distance and after you crash it pops up and says the distance that you traveled.
- Then basically a key input that brings you back to the main Home screen

Author:  Aange10 [ Thu Dec 15, 2011 10:29 pm ]
Post subject:  RE:Helicopter Game Help

In the Turing Walkthrough, you can find answers to most of your questions. I expect you to go through there and read things like Keyboard Input, Mouse detection, etc. The tutorials are there for a reason.

I will help you with a basic algorithm to achieve your aspirations.

- When you read a tutorial on how to track clicking, you'll already be half done. Now just see if the user clicked on the play, and if it did then continue on. (etc)

- Collision detections is also in the walkthrough. The biggest hint I can give you is that there is no 'camera' in Turing. The way you have a camera is your draw things closer/farther to yourself.

- if I start a 0 and my x is now 500 then I've travled 500. SHould be simple.

-You know how to get input, so figure out how to loop to the main menu

Author:  Conrad13 [ Thu Dec 15, 2011 10:48 pm ]
Post subject:  Re: Helicopter Game Help

Thanks for the reply, it did help however still not 100% sure i am capable of like looping back to the main menu, am i supposed to name the loop so it knows what to loop back to or am i supposed to use if, then, input statements?
Also how will i create the flight course? do i need to make like 1000 shapes at which the helicopter must fly through that continuously loop through each other, or do i set it to the the y2 value of a drawfillbox to a random variable?

Author:  Aange10 [ Fri Dec 16, 2011 1:15 am ]
Post subject:  RE:Helicopter Game Help

Easiest thing to do would be to learn about Records and Arrays. From there you can just randomly place obsticles on your path.

There are tons of ways to do one thing, but I'll show you two of the most common.

Here's the easiest one, but it can make a mess sometimes.

Turing:

loop
      % Main menu
      loop
            % Game
            exit when they click menu
      end loop
end loop


However, a better way to go about this, if you know procedures, could be something like this:

Turing:

var gotoMainMenu : boolean := false

proc MainMenu
    var choseOption : boolean := false
    % Draw the main menu, options, etc.
    loop
        % Loop here untill they choose an option
        exit when choseOption = true
    end loop
    gotoMainMenu := false
end MainMenu

loop
    % Run the Game, somewhere in here you will check for the 'exit' key to be pressed
    % When pressed you can toggle the main menu, and reset variables [if you want]
    if gotoMainMenu = true then
        MainMenu
    end if
end loop
   



Study up on records and arrays for your second question. You will need to have a firm grasp on for loops as well.

A general gist of what you'll be doing:

Turing:

% Make a Record
type OData :
    record
        x, y, x2, y2, Color : int
    end record

% Make an array of the record
var obsticles : array 0 .. 30 of OData

% Initialize the array

for i : 0 .. upper (obsticles)
    % There'll be a bit of math here. Try and see whats happening.
    % This way will keep our boxes from just being in a straight line, or
    % on top of each other.
    obsticles (i).x := 150 + (i * 200) % (the 200 is the spacing)
    obsticles (i).y := 100 + (25 * Rand.Int (1, 15)) % This will vary where the y cords of the block are
    obsticles (i).x2 := obsticles (i).x + 20 % 20 is the width
    obsticles (i).y2 := obsticles (i).y + 20 % 20 is the height
    obsticles (i).Color := Rand.Int (7, 14)
end for


% For a visual on how this works;

loop
    cls
    % Move all the blocks over by 20
    for i : 0 .. upper (obsticles)
        obsticles (i).x += -20
        obsticles (i).x2 += -20
    end for
    % Draw them all
    for i : 0 .. upper (obsticles)
        drawfillbox (obsticles (i).x, obsticles (i).y, obsticles (i).x2, obsticles (i).y2, obsticles (i).Color)
    end for
    % My little exit statement to stop when all the obsticles have passed
    if obsticles (upper (obsticles)).x < 0 then
        exit
    end if
    Time.DelaySinceLast (50)
end loop



There are many ways to make this better, and to customize it and optimize it. Hopefully that teaches you the concept a bit, but still read the tutorials.

Nothings set in stone

Author:  Conrad13 [ Fri Dec 16, 2011 1:25 pm ]
Post subject:  Re: Helicopter Game Help

Ok so i managed to update the menu a few.. i only had a few minutes at school but now atleast when the play or controls is selected, the function happens!
This is what i have so far:

var icolor : int
var icolor2 : int
var iXposition : int
var iYposition : int
var xdirection : int
var ydirection : int
var font : int
var font1 : int
var font2 : int
var xmouse, ymouse, button : int
font := Font.New ("serif:50")
font1 := Font.New ("serif:25")
font2 := Font.New ("serif:25")

icolor2 := 21
icolor := 1
iXposition := 0
iYposition := 80
xdirection := 1
ydirection := 1
View.Set ("graphics,offscreenonly")
loop
Mouse.Where(xmouse,ymouse,button)

Draw.Cls

drawfillbox (300,240,350,260,41)


% Background
drawfillbox (0, 0, maxx, maxy, 100)


% Cloud 1
drawfilloval (90, 350, 130, 80, white)
drawfilloval (70, 280, 80, 40, white)
drawfilloval (200, 310, 60, 50, white)
drawfilloval (230, 380, 60, 50, white)

% Cloud 2
drawfilloval (400, 150, 130, 80, white)
drawfilloval (380, 80, 80, 40, white)
drawfilloval (410, 220, 80, 40, white)
drawfilloval (520, 110, 70, 50, white)
drawfilloval (520, 190, 80, 50, white)
drawfilloval (300, 180, 60, 50, white)
drawfilloval (300, 120, 40, 30, white)


% Helicopter
drawfillbox (iXposition + 85, iYposition + 5, iXposition + 155, iYposition + 10, black) % Base Connected to Legs
drawfillbox (iXposition + 100, iYposition + 10, iXposition + 105, iYposition + 20, black) % Base leg 1
drawfillbox (iXposition + 135, iYposition + 10, iXposition + 140, iYposition + 20, black) % Base leg 2
drawfillbox (iXposition + 118, iYposition + 80, iXposition + 123, iYposition + 65, black) % Main Rotor
drawfillbox (iXposition + 25, iYposition + 40, iXposition + 130, iYposition + 50, black) % Rotor rectangle
drawfilloval (iXposition + 120, iYposition + 85, 70, 5, icolor2) % Rotor Blades
drawfilloval (iXposition + 120, iYposition + 45, 40, 30, black) % Cockpit
drawfillbox (iXposition + 10, iYposition + 40, iXposition + 15, iYposition + 70, black) % Rotor rectangle
drawfilloval (iXposition + 15, iYposition + 48, 15, 15, icolor2) % Rear Rotor
drawfilloval (iXposition + 85, iYposition + 45, 20, 15, black) % Smaller circle from main body of helicopter




Draw.Text ("Super-Heli", 190, 25, font, icolor - 1)
Draw.Text ("Play", 300, 240, font1, icolor - 1)
Draw.Text ("Controls", 275, 150, font2, icolor - 1)

if xmouse>290 and xmouse<370 and ymouse>230 and ymouse<280 and button=1 then
Draw.Cls
View.Update
exit
end if
if xmouse>270 and xmouse<390 and ymouse>140 and ymouse<190 and button=1 then
Draw.Cls
View.Update
exit
end if
%drawfillbox (290,230,370,280,41)
%drawfillbox (270,140,390,190,41)
icolor := icolor + 1
if icolor = 62 then
icolor := 1
end if
icolor2 := icolor2 + 1
if icolor2 = 31 then
icolor2 := 21
end if
iXposition := iXposition + xdirection
iYposition := iYposition + ydirection

if iXposition > 445 or iXposition < 0 then
xdirection := -xdirection
end if

if iYposition > 305 or iYposition < 80 then
ydirection := -ydirection
end if

delay (10)
View.Update
end loop

Author:  Aange10 [ Fri Dec 16, 2011 3:36 pm ]
Post subject:  RE:Helicopter Game Help

contrats! And I suggest wrapping your code in

[ syntax = "turing"]
and
[ /syntax ]

Author:  Conrad13 [ Fri Dec 16, 2011 10:40 pm ]
Post subject:  Re: Helicopter Game Help

Thanks Man Helped Me out a lot!! The biggest problem was knowing where to put the separate screens and if i have to loop them separately but I think i have it figured out thanks again! If i need further assistance keep me posted please thank you!

Author:  Conrad13 [ Mon Dec 19, 2011 4:48 pm ]
Post subject:  Re: Helicopter Game Help

Ok, so this is my code so far i know i do not have the game going yet however I feel the need to update my post Smile
[ syntax = "turing"]
var icolor : int
var icolor2 : int
var iXposition : int
var iYposition : int
var xdirection : int
var ydirection : int
var font : int
var font1 : int
var font2 : int
var font3 : int
var xmouse, ymouse, button : int
var ch : string (1)

font := Font.New ("serif:50")
font1 := Font.New ("serif:25")
font2 := Font.New ("serif:15")
font3 := Font.New ("serif:9")

icolor2 := 21
icolor := 1
iXposition := 0
iYposition := 0
xdirection := 1
ydirection := 1
View.Set ("graphics,offscreenonly,nocursor")
loop
Mouse.Where(xmouse,ymouse,button)

Draw.Cls

drawfillbox (300,240,350,260,41)


% Background
drawfillbox (0, 0, maxx, maxy, 100)


% Cloud 1
drawfilloval (90, 350, 130, 80, white)
drawfilloval (70, 280, 80, 40, white)
drawfilloval (200, 310, 60, 50, white)
drawfilloval (230, 380, 60, 50, white)

% Cloud 2
drawfilloval (400, 150, 130, 80, white)
drawfilloval (380, 80, 80, 40, white)
drawfilloval (410, 220, 80, 40, white)
drawfilloval (520, 110, 70, 50, white)
drawfilloval (520, 190, 80, 50, white)
drawfilloval (300, 180, 60, 50, white)
drawfilloval (300, 120, 40, 30, white)


% Helicopter
drawfillbox (iXposition + 85, iYposition + 5, iXposition + 155, iYposition + 10, black) % Base Connected to Legs
drawfillbox (iXposition + 100, iYposition + 10, iXposition + 105, iYposition + 20, black) % Base leg 1
drawfillbox (iXposition + 135, iYposition + 10, iXposition + 140, iYposition + 20, black) % Base leg 2
drawfillbox (iXposition + 118, iYposition + 80, iXposition + 123, iYposition + 65, black) % Main Rotor
drawfillbox (iXposition + 25, iYposition + 40, iXposition + 130, iYposition + 50, black) % Rotor rectangle
drawfilloval (iXposition + 120, iYposition + 85, 70, 5, icolor2) % Rotor Blades
drawfilloval (iXposition + 120, iYposition + 45, 40, 30, black) % Cockpit
drawfillbox (iXposition + 10, iYposition + 40, iXposition + 15, iYposition + 70, black) % Rotor rectangle
drawfilloval (iXposition + 15, iYposition + 48, 15, 15, icolor2) % Rear Rotor
drawfilloval (iXposition + 85, iYposition + 45, 20, 15, black) % Smaller circle from main body of helicopter




Draw.Text ("Super-Heli", 190, 325, font, icolor - 1)
Draw.Text ("Play", 300, 180, font1, icolor - 1)
Draw.Text ("Controls", 275, 120, font1, icolor - 1)

% Play
if xmouse>290 and xmouse<370 and ymouse>170 and ymouse<220 and button=1 then
Draw.Cls
Draw.Text ("CONGRATS, You Lose!", 175, 200, font1, black)
View.Update
exit
end if







% Controls
if xmouse>270 and xmouse<390 and ymouse>100 and ymouse<150 and button=1 then
Draw.Cls
View.Update

loop
drawfillbox (0, 0, maxx, maxy, 100)

% Cloud 1
drawfilloval (90, 350, 130, 80, white)
drawfilloval (70, 280, 80, 40, white)
drawfilloval (200, 310, 60, 50, white)
drawfilloval (230, 380, 60, 50, white)

% Cloud 2
drawfilloval (400, 150, 130, 80, white)
drawfilloval (380, 80, 80, 40, white)
drawfilloval (410, 220, 80, 40, white)
drawfilloval (520, 110, 70, 50, white)
drawfilloval (520, 190, 80, 50, white)
drawfilloval (300, 180, 60, 50, white)
drawfilloval (300, 120, 40, 30, white)
Draw.Text ("Controls", 265, 335, font1, black)
Draw.Text ("Press B to go Back", 15, 360, font2, black)
Draw.Text ("Welcome to Super-Heli, the classic game that never gets boring!", 70, 285, font2, black)
Draw.Text ("The controls of this game are basic, to raise your helicopter,", 80, 255, font2, black)
Draw.Text ("simply click your mouse to ascend your helicopter vertically,", 77, 225, font2, black)
Draw.Text ("to descend your helicopter, let go of the mouse button.", 100, 195, font2, black)
Draw.Text ("Good luck and have fun!", 230, 165, font2, black)
Draw.Text ("Trademark to the IGC (International Gaming Corporation) Do not copy this game.", 115, 15, font3, black)

View.Update
getch (ch)
if ch = "b" then
exit
else
end if

end loop


else
end if


%drawfillbox (290,170,370,220,41)
%drawfillbox (270,100,390,150,41)
icolor := icolor + 1
if icolor = 62 then
icolor := 1
end if
icolor2 := icolor2 + 1
if icolor2 = 31 then
icolor2 := 21
end if
iXposition := iXposition + xdirection
iYposition := iYposition + ydirection

if iXposition > 455 or iXposition < 0 then
xdirection := -xdirection
end if

if iYposition > 215 or iYposition < 0 then
ydirection := -ydirection
end if


delay (0)
View.Update
end loop

[ /syntax ]
I could use some help as to where to start my game Sad.
Like i do no know where to start, i feel if i get a start i can move from there any ideas?
Thanks to all contributor(s) <<<----- so far Razz aka Aange10

Author:  Conrad13 [ Tue Dec 20, 2011 7:05 pm ]
Post subject:  Re: Helicopter Game Help

BUMP Help me please?
Can someone show me a detailed turing code to help me start the environment in which the helicopter will be passing through, like the original game, i need random obstacle relays and pleeasseee help me i do not know where to start.
Sad Sad Sad Sad Sad

Author:  Aange10 [ Tue Dec 20, 2011 7:30 pm ]
Post subject:  RE:Helicopter Game Help

Sorry for not being specific, when you use the BBC codes ([ /syntax] and what not) you don't add the spaces.

Conrad13 wrote:

Can someone show me a detailed turing code to help me start the environment in which the helicopter will be passing through,i need random obstacle relays



I beleive the code ^ Just showed you how to make this 'environment' with random obstacles.

Author:  Conrad13 [ Tue Dec 20, 2011 9:00 pm ]
Post subject:  Re: Helicopter Game Help

My, bad I did not see that post :S so sorry, and I have another question:
- In the real game the bottom of the screen has a floor and the top, a roof so basically you are flying through a cave and you are dodging rectangles that protrude from the roof or the floor would it be possible to do something like that instead of shapes flying toward you?

Author:  Aange10 [ Tue Dec 20, 2011 9:57 pm ]
Post subject:  Re: Helicopter Game Help

Conrad13 @ 20/12/2011, 8:00 pm wrote:
would it be possible to do something like that instead of shapes flying toward you?



Aange10 wrote:
Nothings set in stone

Author:  Aange10 [ Tue Dec 20, 2011 9:58 pm ]
Post subject:  RE:Helicopter Game Help

Specifically
Turing:


    cls
    % Move all the blocks over by 20
    for i : 0 .. upper (obsticles)
        obsticles (i).x += -20
        obsticles (i).x2 += -20

Author:  Conrad13 [ Thu Dec 22, 2011 3:25 pm ]
Post subject:  Re: Helicopter Game Help

Turing:

% My Variables
var xpositiona, y1, y2,dummy : int
xpositiona := 640
y1 := Rand.Int(0,400)
y2 :=Rand.Int(0,400)

var icolor, icolor2, iXposition, iYposition, xdirection, ydirection, font, font1, font2, font3, xmouse, ymouse, button : int
% Helicopter Controls
var yaltitude, mx, my, btn : int

var ch : string (1)

% Text Fonts
font := Font.New ("serif:50")
font1 := Font.New ("serif:25")
font2 := Font.New ("serif:15")
font3 := Font.New ("serif:9")

% Colors
icolor2 := 21
icolor := 1


% Positions
iXposition := 0
iYposition := 0
xdirection := 1
ydirection := 1
yaltitude := 0
View.Set ("graphics,offscreenonly,nocursor")

% Menu
loop
Mouse.Where(xmouse,ymouse,button)

Draw.Cls
% Background
drawfillbox (300,240,350,260,41)


% Background
drawfillbox (0, 0, maxx, maxy, 100)


% Cloud 1
drawfilloval (90, 350, 130, 80, white)
drawfilloval (70, 280, 80, 40, white)
drawfilloval (200, 310, 60, 50, white)
drawfilloval (230, 380, 60, 50, white)

% Cloud 2
drawfilloval (400, 150, 130, 80, white)
drawfilloval (380, 80, 80, 40, white)
drawfilloval (410, 220, 80, 40, white)
drawfilloval (520, 110, 70, 50, white)
drawfilloval (520, 190, 80, 50, white)
drawfilloval (300, 180, 60, 50, white)
drawfilloval (300, 120, 40, 30, white)


% Helicopter
drawfillbox (iXposition + 85, iYposition + 5, iXposition + 155, iYposition + 10, black) % Base Connected to Legs
drawfillbox (iXposition + 100, iYposition + 10, iXposition + 105, iYposition + 20, black) % Base leg 1
drawfillbox (iXposition + 135, iYposition + 10, iXposition + 140, iYposition + 20, black) % Base leg 2
drawfillbox (iXposition + 118, iYposition + 80, iXposition + 123, iYposition + 65, black) % Main Rotor
drawfillbox (iXposition + 25, iYposition + 40, iXposition + 130, iYposition + 50, black) % Rotor rectangle
drawfilloval (iXposition + 120, iYposition + 85, 70, 5, icolor2) % Rotor Blades
drawfilloval (iXposition + 120, iYposition + 45, 40, 30, black) % Cockpit
drawfillbox (iXposition + 10, iYposition + 40, iXposition + 15, iYposition + 70, black) % Rotor rectangle
drawfilloval (iXposition + 15, iYposition + 48, 15, 15, icolor2) % Rear Rotor
drawfilloval (iXposition + 85, iYposition + 45, 20, 15, black) % Smaller circle from main body of helicopter



% Menu Selections
Draw.Text ("Super-Heli", 190, 325, font, icolor - 1)
Draw.Text ("Play", 300, 180, font1, icolor - 1)
Draw.Text ("Controls", 275, 120, font1, icolor - 1)


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% If Played %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if xmouse>290 and xmouse<370 and ymouse>170 and ymouse<220 and button=1 then
Draw.Cls
View.Update

%%% Background %%%
loop

drawfillbox (0, 0, maxx, maxy, 100)
drawfillbox (0, 0, 640, 50, white)
drawfillbox (0, 350, maxx, maxy, white)
drawfillbox (xpositiona, y1, xpositiona+40,y2,white)
xpositiona:= xpositiona-1

if xpositiona <0 then
xpositiona := 640
dummy:=Rand.Int(50,350)
if dummy <= 200 then
y1 := 50
y2 := dummy
else
y1 := 350
y2 := dummy
end if
end if

%Helicopter
drawfillbox (75, 192+yaltitude, 125, 196+yaltitude, black) % Base Connected to Legs
drawfillbox (90, 192+yaltitude, 95, 200+yaltitude, black) % Base leg 1
drawfillbox (107, 192+yaltitude, 112, 210+yaltitude, black) % Base leg 2
drawfillbox (97, 240+yaltitude, 102, 249+yaltitude, black) % Main Rotor Rectangle
drawfillbox (25, 218+yaltitude, 110, 223+yaltitude, black) % Rotor rectangle
drawfilloval (100, 248+yaltitude, 50, 5, icolor2) % Rotor Blades
drawfilloval (100, 220+yaltitude, 30, 20, black) % Cockpit
drawfillbox (24, 215+yaltitude, 27, 238+yaltitude, black) % Rotor rectangle
drawfilloval (24, 223+yaltitude, 10, 10, icolor2) % Rear Rotor Blades
drawfilloval (75, 220+yaltitude, 15, 10, black) % Smaller circle from main body of helicopter
View.Update

icolor2 := icolor2 + 1

mousewhere (mx, my, btn)
if btn = 1 then
yaltitude+=1


else
yaltitude-=1
View.Update

end if
if icolor2 = 31 then
icolor2 := 21
end if

delay (2)
end loop
end if
%%% End Background %%%





% If Controls selected
if xmouse>270 and xmouse<390 and ymouse>100 and ymouse<150 and button=1 then
Draw.Cls
View.Update

loop
drawfillbox (0, 0, maxx, maxy, 100)

% Cloud 1
drawfilloval (90, 350, 130, 80, white)
drawfilloval (70, 280, 80, 40, white)
drawfilloval (200, 310, 60, 50, white)
drawfilloval (230, 380, 60, 50, white)

% Cloud 2
drawfilloval (400, 150, 130, 80, white)
drawfilloval (380, 80, 80, 40, white)
drawfilloval (410, 220, 80, 40, white)
drawfilloval (520, 110, 70, 50, white)
drawfilloval (520, 190, 80, 50, white)
drawfilloval (300, 180, 60, 50, white)
drawfilloval (300, 120, 40, 30, white)
Draw.Text ("Controls", 265, 335, font1, black)
Draw.Text ("Press B to go Back", 15, 360, font2, black)
Draw.Text ("Welcome to Super-Heli, the classic game that never gets boring!", 70, 285, font2, black)
Draw.Text ("The controls of this game are basic, to raise your helicopter,", 80, 255, font2, black)
Draw.Text ("simply click your mouse to ascend your helicopter vertically,", 77, 225, font2, black)
Draw.Text ("to descend your helicopter, let go of the mouse button.", 100, 195, font2, black)
Draw.Text ("Good luck and have fun!", 230, 125, font2, black)
Draw.Text ("Trademark to the IGC (International Gaming Corporation) Do not copy this game.", 115, 15, font3, black)

View.Update
getch (ch)
if ch = "b" then
exit
else
end if

end loop


else
end if


%drawfillbox (290,170,370,220,41)
%drawfillbox (270,100,390,150,41)




icolor := icolor + 1
if icolor = 62 then
icolor := 1
end if
icolor2 := icolor2 + 1
if icolor2 = 31 then
icolor2 := 21
end if
iXposition := iXposition + xdirection
iYposition := iYposition + ydirection

if iXposition > 455 or iXposition < 0 then
xdirection := -xdirection
end if

if iYposition > 215 or iYposition < 0 then
ydirection := -ydirection
end if


delay (10)
View.Update

end loop

Well its coming together, now all I have to do is setup the collision detection, distance counter, and gameover!!!
Thanks Aange10

Author:  Aange10 [ Thu Dec 22, 2011 4:20 pm ]
Post subject:  RE:Helicopter Game Help

the Turing Walkthrough has collison tutorials. Considering how easy this is, you may want to look into Whatdotcolor collision.

Author:  Conrad13 [ Thu Dec 22, 2011 5:11 pm ]
Post subject:  RE:Helicopter Game Help

I still have no idea what to do with that... Sad

Author:  Aange10 [ Thu Dec 22, 2011 5:33 pm ]
Post subject:  RE:Helicopter Game Help

Here's an example of using whatdotcolor.

Turing:

% Our Character
var charx : int := 100
var chary : int := 100

% Our Enemy
var targetx : int
var targety : int

% Get Input
var num : array char of boolean

% Set double buffering
setscreen ("offscreenonly")

% begin mini game
loop
    % Ramdomize target's location
    targetx := Rand.Int (10, 630) %just setting the coordinates of the target
    targety := Rand.Int (10, 390) % In the brackets is just the rang of the Rand.Int!
    loop
        Input.KeyDown (num) %Remember this from 'Movement'?
        if num (KEY_UP_ARROW) and chary < 390 then
            chary := chary + 1
        end if
        if num (KEY_DOWN_ARROW) and chary > 10 then
            chary := chary - 1
        end if
        if num (KEY_LEFT_ARROW) and charx > 10 then
            charx := charx - 1
        end if
        if num (KEY_RIGHT_ARROW) and charx < 630 then
            charx := charx + 1
        end if
       
        % Draw everything
        Draw.FillOval (targetx, targety, 20, 20, black)
        Draw.Oval (charx, chary, 5, 5, brightred)
        colourback (0) put "targetx:", targetx
        colourback (0) put "targety:", targety
       
        % ONE line of collision
        exit when whatdotcolor (charx, chary) = black
        View.Update
        delay (5)
        cls
    end loop
    cls
end loop

% Taken from the Whatdotcolor tutorial



Author:  Conrad13 [ Thu Dec 22, 2011 5:46 pm ]
Post subject:  RE:Helicopter Game Help

: / still dont get this

Author:  Aange10 [ Thu Dec 22, 2011 6:39 pm ]
Post subject:  RE:Helicopter Game Help

What part do you not get?

Author:  Conrad13 [ Thu Dec 22, 2011 7:12 pm ]
Post subject:  RE:Helicopter Game Help

thanks, but never mind ill try and figure it out

Author:  Conrad13 [ Thu Dec 22, 2011 9:02 pm ]
Post subject:  Re: Helicopter Game Help

Can anyone help me with color collision detection?!! Please out of all the people on the forum how do i only have one person trying to help?!!? Sad

Author:  chipanpriest [ Thu Dec 22, 2011 9:27 pm ]
Post subject:  Re: Helicopter Game Help

Turing:
if whatdotcolor (x,y) = col then
exit
end if

Think that would work?

Author:  Aange10 [ Thu Dec 22, 2011 9:46 pm ]
Post subject:  RE:Helicopter Game Help

Indeed, whatdotcolor is very simple. you put in the x cord, and the y cord, and it tells you what color that dot is. Simple.


So you could look at the edge of your helicopter, and say "if this dot turns white, exit". To do that you'd say whatdotcolor (theDotsXposition, theDotsYposition). That'd give you the color of that dot, then you'd take it and compare it and see if its white.

Turing:

if whatdotcolor (theDotsXposition, theDotsYposition) = white then
exit
end if

Author:  chipanpriest [ Thu Dec 22, 2011 9:59 pm ]
Post subject:  Re: Helicopter Game Help

for the ceiling and floor you could put
Turing:
if helicoptery >= maxy then
exit
elsif helicoptery <= 0 then
exit
end if

Author:  chipanpriest [ Thu Dec 22, 2011 10:04 pm ]
Post subject:  RE:Helicopter Game Help

also i played it and sometimes the dummy takes up the whole screen, thus making it impossible once you get the collision code in there. you might want to fix that :p

Author:  Dreadnought [ Fri Dec 23, 2011 12:47 am ]
Post subject:  Re: Helicopter Game Help

Basically to check collision we use whatdotcolour to check if any pixels are the "wrong" colour. If any are then we have a collision. So which pixels should we check? Well lets suppose we are moving a box around on the screen. We could check every single pixel in the box, but that's a lot of pixels (remember we are doing this on each frame) and common sense/laziness tells us we can do better.

We can reason fairly easily that only the edges are important (for more complex shapes some edges may not be important if they are on the inside of the shape). For that box I was talking about we would only have to check the pixels at the edges of the box.

In your case you would want to know where the important edges of your helicopter are. Think of it like a wire frame. Here's what it might look like for your helicopter.
Turing:
Draw.FillBox (50,348,150,353,12)
Draw.FillBox (75, 292, 125, 294, 12)
Draw.FillBox (20,312,70,320,12)
drawbox (75, 192+100, 125, 196+100, black) % Base Connected to Legs
drawbox (90, 192+100, 95, 200+100, black) % Base leg 1
drawbox (107, 192+100, 112, 210+100, black) % Base leg 2
drawbox (97, 240+100, 102, 249+100, black) % Main Rotor Rectangle
drawbox (25, 218+100, 110, 223+100, black) % Rotor rectangle
drawoval (100, 248+100, 50, 5, 7) % Rotor Blades
drawoval (100, 220+100, 30, 20, black) % Cockpit
drawbox (24, 215+100, 27, 238+100, black) % Rotor rectangle
drawoval (24, 223+100, 10, 10, 7) % Rear Rotor Blades
drawoval (75, 220+100, 15, 10, black) % Smaller circle from main body of helicopter 

The red rectangles are a ruff estimate of some of the areas where you might want to check for collisions on edges.

Now to check for collision. Aange10 posted a nice example for this. Here's my "moving a box around" example that I was talking about earlier. In this example I stop the box from moving when I detect collision.
Turing:
View.Set ("offscreenonly")
var x : int := 299 % x position
var y : int := 299 % y position
fcn x2 : int % the other x position
    result x + 20
end x2
fcn y2 : int % the other y position
    result y + 20
end y2
const speed := 1
var chars : array char of boolean
% Draw the border
Draw.FillBox (0, 0, maxx, maxy, 7)
Draw.FillBox (10, 10, maxx - 10, maxy - 10, 0)
View.Update
loop
    Draw.FillBox (x, y, x2, y2, 0) % Erase the box
    Input.KeyDown (chars)
    if chars (KEY_LEFT_ARROW) then
        x -= speed
    end if
    if chars (KEY_RIGHT_ARROW) then
        x += speed
    end if
    if chars (KEY_DOWN_ARROW) then
        y -= speed
    end if
    if chars (KEY_UP_ARROW) then
        y += speed
    end if
    for i : 0 .. 20 % check all dots on each edge
        if whatdotcolour (x, y + i) = 7 then % check left edge
            x += speed
        elsif whatdotcolour (x2, y + i) = 7 then % check right edge
            x -= speed
        end if
        if whatdotcolour (x + i, y) = 7 then % check bottom edge
            y += speed
        elsif whatdotcolour (x + i, y2) = 7 then % check top edge
            y -= speed
        end if
    end for
    Draw.FillBox (x, y, x2, y2, 12) % Draw the box
    View.UpdateArea (x - speed, y - speed, x2 + speed, y2 + speed) % Update the box on screen
    Time.Delay (5)
end loop

Basically I'm checking if any pixel in the 4 lines that make up my box are touching black. If they are I stop the box.
Of course one might look at this and say "Just check the x and y coordinates of the box to find when it hits the border". Its true, that would be faster and easier. BUT, add ANY shape you want to the screen (make in black and don't put it where the box is when the program starts) and it will still work. For example, try copying your helicopter's frame I posted above into the section that says "%You can add other shapes here".

So now you have a square that will always stop when it collides with any black object. (There is a bug that will sometimes cause the box to slide on edges, but its should be easy to fix)

Since you only care about whether or not you collided your task is even simpler.

Note: Straight lines are easy to check, curves are harder. For an oval you can either estimate it as a rectangle (easy but not very accurate), or check points on the actual oval (the formula for an oval is (x/a)^2 + (y/b)^2 = 1 where a is the horizontal radius and b is the vertical radius).

Hope this helps.

Author:  Conrad13 [ Fri Dec 23, 2011 8:37 am ]
Post subject:  RE:Helicopter Game Help

o.O wow thanks for all the help, lol, i think i can take it from here, do you guys think this is a good game? like idk rate this outta 10 for what it has potential for?? Sad Smile
Again thanks for all the help

Author:  Aange10 [ Fri Dec 23, 2011 2:45 pm ]
Post subject:  RE:Helicopter Game Help

It's very classic, I like it. There is no reason to rate it. For a society used to industry standard, rating a new programmers game is harsh.

Author:  chipanpriest [ Fri Dec 23, 2011 4:09 pm ]
Post subject:  RE:Helicopter Game Help

I actually like it, you just need to add to it and it would be great

Author:  Conrad13 [ Fri Dec 23, 2011 5:28 pm ]
Post subject:  RE:Helicopter Game Help

Aww thanks people!! Can't wait to post the finished product

Author:  Aange10 [ Fri Dec 23, 2011 6:57 pm ]
Post subject:  RE:Helicopter Game Help

Can't wait to see it.

Author:  Conrad13 [ Mon Jan 09, 2012 4:54 pm ]
Post subject:  Re: Helicopter Game Help

Turing:


% My Variables
  var xpositiona, y1, y2,dummy : int
    xpositiona := 640
    y1 := Rand.Int(0,400)
    y2 :=Rand.Int(0,400)
   
var icolor, icolor2, iXposition, iYposition, xdirection, ydirection, font, font1, font2, font3, xmouse, ymouse, button : int
% Helicopter Controls
var yaltitude, mx, my, btn : int

var ch : string (1)

% Text Fonts
font := Font.New ("serif:50")
font1 := Font.New ("serif:25")
font2 := Font.New ("serif:15")
font3 := Font.New ("serif:9")

% Colors
icolor2 := 21
icolor := 1


% Positions
iXposition := 0
iYposition := 0
xdirection := 1
ydirection := 1
yaltitude  := 0
View.Set ("graphics,offscreenonly,nocursor")
   
    % Menu
    loop
    Mouse.Where(xmouse,ymouse,button)

    Draw.Cls
    % Background
    drawfillbox (300,240,350,260,41)


    % Background
    drawfillbox (0, 0, maxx, maxy, 100)


    % Cloud 1
    drawfilloval (90, 350, 130, 80, white)
    drawfilloval (70, 280, 80, 40, white)
    drawfilloval (200, 310, 60, 50, white)
    drawfilloval (230, 380, 60, 50, white)

    % Cloud 2
    drawfilloval (400, 150, 130, 80, white)
    drawfilloval (380, 80, 80, 40, white)
    drawfilloval (410, 220, 80, 40, white)
    drawfilloval (520, 110, 70, 50, white)
    drawfilloval (520, 190, 80, 50, white)
    drawfilloval (300, 180, 60, 50, white)
    drawfilloval (300, 120, 40, 30, white)


    % Helicopter
    drawfillbox (iXposition + 85, iYposition + 5, iXposition + 155, iYposition + 10, black) % Base Connected to Legs
    drawfillbox (iXposition + 100, iYposition + 10, iXposition + 105, iYposition + 20, black) % Base leg 1
    drawfillbox (iXposition + 135, iYposition + 10, iXposition + 140, iYposition + 20, black) % Base leg 2
    drawfillbox (iXposition + 118, iYposition + 80, iXposition + 123, iYposition + 65, black) % Main Rotor
    drawfillbox (iXposition + 25, iYposition + 40, iXposition + 130, iYposition + 50, black) % Rotor rectangle
    drawfilloval (iXposition + 120, iYposition + 85, 70, 5, icolor2) % Rotor Blades
    drawfilloval (iXposition + 120, iYposition + 45, 40, 30, black) % Cockpit
    drawfillbox (iXposition + 10, iYposition + 40, iXposition + 15, iYposition + 70, black) % Rotor rectangle
    drawfilloval (iXposition + 15, iYposition + 48, 15, 15, icolor2) % Rear Rotor
    drawfilloval (iXposition + 85, iYposition + 45, 20, 15, black) % Smaller circle from main body of helicopter



    % Menu Selections
    Draw.Text ("Super-Heli", 190, 325, font, icolor - 1)
    Draw.Text ("Play", 300, 180, font1, icolor - 1)
    Draw.Text ("Controls", 275, 120, font1, icolor - 1)
   
   
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%              If Played                 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   
    if xmouse>290 and xmouse<370 and ymouse>170 and ymouse<220 and button=1 then
    Draw.Cls
    View.Update
   
    %%% Background %%%
    loop
   
    drawfillbox (0, 0, maxx, maxy, 100)
    drawfillbox (0, 0, 640, 50, white)
    drawfillbox (0, 350, maxx, maxy, white)
    drawfillbox (xpositiona, y1, xpositiona+40,y2,white)
    xpositiona:= xpositiona-1
   
    if xpositiona <0 then
    xpositiona := 640
     dummy:=Rand.Int(50,350)
    if dummy <= 200 then
    y1 := 50
    y2 := dummy
    else
    y1 := 350
    y2 := dummy
    end if
    end if
   
    %Helicopter
    drawfillbox (75, 192+yaltitude, 125, 196+yaltitude, black) % Base Connected to Legs
    drawfillbox (90, 192+yaltitude, 95, 200+yaltitude, black) % Base leg 1
    drawfillbox (107, 192+yaltitude, 112, 210+yaltitude, black) % Base leg 2
    drawfillbox (97, 240+yaltitude, 102, 249+yaltitude, black) % Main Rotor Rectangle
    drawfillbox (25, 218+yaltitude, 110, 223+yaltitude, black) % Rotor rectangle
    drawfilloval (100, 248+yaltitude, 50, 5, icolor2) % Rotor Blades
    drawfilloval (100, 220+yaltitude, 30, 20, black) % Cockpit
    drawfillbox (24, 215+yaltitude, 27, 238+yaltitude, black) % Rotor rectangle
    drawfilloval (24, 223+yaltitude, 10, 10, icolor2) % Rear Rotor Blades
    drawfilloval (75, 220+yaltitude, 15, 10, black) % Smaller circle from main body of helicopter
    View.Update
   
    icolor2 := icolor2 + 1
   
    mousewhere (mx, my, btn)
    if btn = 1 then
    yaltitude+=1
    else
     yaltitude-=1     
    end if
    if icolor2 = 31 then
        icolor2 := 21
    end if
   
    if whatdotcolor (125, 192+yaltitude) = white then
    exit
    end if
   
    if whatdotcolor (150, 253+yaltitude) = white then
    exit
    end if
       
    delay (3)
    end loop
    end if
   
    if whatdotcolor (125, 192+yaltitude) = white then
    exit
    end if
    %%% End Background %%%
   
   
   

   
   
    % If Controls selected
    if xmouse>270 and xmouse<390 and ymouse>100 and ymouse<150 and button=1 then
    Draw.Cls
    View.Update
   
    loop
    drawfillbox (0, 0, maxx, maxy, 100)
   
    % Cloud 1
    drawfilloval (90, 350, 130, 80, white)
    drawfilloval (70, 280, 80, 40, white)
    drawfilloval (200, 310, 60, 50, white)
    drawfilloval (230, 380, 60, 50, white)

    % Cloud 2
    drawfilloval (400, 150, 130, 80, white)
    drawfilloval (380, 80, 80, 40, white)
    drawfilloval (410, 220, 80, 40, white)
    drawfilloval (520, 110, 70, 50, white)
    drawfilloval (520, 190, 80, 50, white)
    drawfilloval (300, 180, 60, 50, white)
    drawfilloval (300, 120, 40, 30, white)
    Draw.Text ("Controls", 265, 335, font1, black)
    Draw.Text ("Press B to go Back", 15, 360, font2, black)
    Draw.Text ("Welcome to Super-Heli, the classic game that never gets boring!", 70, 285, font2, black)
    Draw.Text ("The controls of this game are basic, to raise your helicopter,", 80, 255, font2, black)
    Draw.Text ("simply click your mouse to ascend your helicopter vertically,", 77, 225, font2, black)
    Draw.Text ("to descend your helicopter, let go of the mouse button.", 100, 195, font2, black)
    Draw.Text ("But be careful don't touch the white sections or its game over!", 70, 165, font2, black)
    Draw.Text ("Good luck and have fun!", 230, 125, font2, black)
    Draw.Text ("Trademark to the IGC (International Gaming Corporation) Do not copy this game.", 115, 15, font3, black)
   
    View.Update
    getch (ch)
    if ch = "b" then
    exit
    else
    end if
   
    end loop
   
   
    else
    end if

   
    %drawfillbox (290,170,370,220,41)
    %drawfillbox (270,100,390,150,41)
   
   
   
   
    icolor := icolor + 1
    if icolor = 62 then
        icolor := 1
    end if
    icolor2 := icolor2 + 1
    if icolor2 = 31 then
        icolor2 := 21
    end if
    iXposition := iXposition + xdirection
    iYposition := iYposition + ydirection

    if iXposition > 455 or iXposition < 0 then
        xdirection := -xdirection
    end if

    if iYposition > 215 or iYposition < 0 then
        ydirection := -ydirection
    end if
   

    %delay (5)
    View.Update

end loop



If You really try and play and hit white, then it returns to the main menu, however, click play again and it returns to previous and totally glitches up.

Okay, so I have this but i think as was stated earlier my dummy overtakes the exit command and it all F***s Up lol, does anyone have an idea whats happening, and sorry i took so long past three weeks haven't been home and had no time what so ever.

Author:  Aange10 [ Mon Jan 09, 2012 5:29 pm ]
Post subject:  RE:Helicopter Game Help

Okay, well your problem is very simple.


This section

[syntax="turing]
if whatdotcolor (125, 192+yaltitude) = white then
exit
end if

if whatdotcolor (150, 253+yaltitude) = white then
exit
end if

delay (3)
end loop
end if

if whatdotcolor (125, 192+yaltitude) = white then
exit
end if
[/syntax]

If the color is white it exits the loop, and then if the bottom of the helicopter is white, it exits the entire program.

Author:  Conrad13 [ Mon Jan 09, 2012 6:57 pm ]
Post subject:  RE:Helicopter Game Help

So, how do i make it exit the entire program, or how do i solve it, you merely said what the problem is.

Author:  Aange10 [ Mon Jan 09, 2012 7:00 pm ]
Post subject:  RE:Helicopter Game Help

It already exits the entire program


Quote:

If the color is white it exits the loop, and then if the bottom of the helicopter is white, it exits the entire program.

Author:  Conrad13 [ Mon Jan 09, 2012 7:07 pm ]
Post subject:  RE:Helicopter Game Help

okay, my bad, in the post where i stated my code the part after the delay (3) end loop end if i took off and I dont know how to make it go back to the main menu, but it doesn't work.
Do you not see the glitch? its totally screwing up

Author:  Aange10 [ Mon Jan 09, 2012 7:39 pm ]
Post subject:  RE:Helicopter Game Help

I took off the if statement on line 146, and the program does everything as you intended. Your menus work correctly, and it correctly sends you back if you hit white.




The reason you're helicopter isn't resetting.. Your not resetting it. Simple as that.

Author:  Conrad13 [ Wed Jan 11, 2012 7:03 pm ]
Post subject:  RE:Helicopter Game Help

I do not know what you are doing but i took out the if statement and it still screws uppp!! try hitting the top, how to i make it loop back to the menu and RESET the game part?

Author:  Alex C. [ Wed Jan 11, 2012 9:25 pm ]
Post subject:  RE:Helicopter Game Help

i fixed it and added a crappy gameover screen for you Very Happy The only actual problem was that you forgot to create another loop so that once it exits, your game resets AND you need to reset the helicopter location each time...

Turing:


% My Variables
var xpositiona, y1, y2, dummy : int
xpositiona := 400
y1 := Rand.Int (200, 400)
y2 := Rand.Int (200, 400)

var icolor, icolor2, iXposition, iYposition, xdirection, ydirection, font, font1, font2, font3, xmouse, ymouse, button : int
% Helicopter Controls
var yaltitude, mx, my, btn : int

var ch : string (1)

% Text Fonts
font := Font.New ("serif:50")
font1 := Font.New ("serif:25")
font2 := Font.New ("serif:15")
font3 := Font.New ("serif:9")

% Colors
icolor2 := 21
icolor := 1


% Positions
iXposition := 0
iYposition := 0
xdirection := 1
ydirection := 1
yaltitude := 0
View.Set ("graphics,offscreenonly,nocursor")


loop
    yaltitude := 0
    % Menu
    loop
        Mouse.Where (xmouse, ymouse, button)

        Draw.Cls
        % Background
        drawfillbox (300, 240, 350, 260, 41)


        % Background
        drawfillbox (0, 0, maxx, maxy, 100)


        % Cloud 1
        drawfilloval (90, 350, 130, 80, white)
        drawfilloval (70, 280, 80, 40, white)
        drawfilloval (200, 310, 60, 50, white)
        drawfilloval (230, 380, 60, 50, white)

        % Cloud 2
        drawfilloval (400, 150, 130, 80, white)
        drawfilloval (380, 80, 80, 40, white)
        drawfilloval (410, 220, 80, 40, white)
        drawfilloval (520, 110, 70, 50, white)
        drawfilloval (520, 190, 80, 50, white)
        drawfilloval (300, 180, 60, 50, white)
        drawfilloval (300, 120, 40, 30, white)


        % Helicopter
        drawfillbox (iXposition + 85, iYposition + 5, iXposition + 155, iYposition + 10, black) % Base Connected to Legs
        drawfillbox (iXposition + 100, iYposition + 10, iXposition + 105, iYposition + 20, black) % Base leg 1
        drawfillbox (iXposition + 135, iYposition + 10, iXposition + 140, iYposition + 20, black) % Base leg 2
        drawfillbox (iXposition + 118, iYposition + 80, iXposition + 123, iYposition + 65, black) % Main Rotor
        drawfillbox (iXposition + 25, iYposition + 40, iXposition + 130, iYposition + 50, black) % Rotor rectangle
        drawfilloval (iXposition + 120, iYposition + 85, 70, 5, icolor2) % Rotor Blades
        drawfilloval (iXposition + 120, iYposition + 45, 40, 30, black) % Cockpit
        drawfillbox (iXposition + 10, iYposition + 40, iXposition + 15, iYposition + 70, black) % Rotor rectangle
        drawfilloval (iXposition + 15, iYposition + 48, 15, 15, icolor2) % Rear Rotor
        drawfilloval (iXposition + 85, iYposition + 45, 20, 15, black) % Smaller circle from main body of helicopter



        % Menu Selections
        Draw.Text ("Super-Heli", 190, 325, font, icolor - 1)
        Draw.Text ("Play", 300, 180, font1, icolor - 1)
        Draw.Text ("Controls", 275, 120, font1, icolor - 1)


        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%              If Played                 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        if xmouse > 290 and xmouse < 370 and ymouse > 170 and ymouse < 220 and button = 1 then
            Draw.Cls
            View.Update

            %%% Background %%%
            loop

                drawfillbox (0, 0, maxx, maxy, 100)
                drawfillbox (0, 0, 640, 50, white)
                drawfillbox (0, 350, maxx, maxy, white)
                drawfillbox (xpositiona, y1, xpositiona + 40, y2, white)
                xpositiona := xpositiona - 1

                if xpositiona < 0 then
                    xpositiona := 640
                    dummy := Rand.Int (50, 350)
                    if dummy <= 200 then
                        y1 := 50
                        y2 := dummy
                    else
                        y1 := 350
                        y2 := dummy
                    end if
                end if

                %Helicopter
                drawfillbox (75, 192 + yaltitude, 125, 196 + yaltitude, black) % Base Connected to Legs
                drawfillbox (90, 192 + yaltitude, 95, 200 + yaltitude, black) % Base leg 1
                drawfillbox (107, 192 + yaltitude, 112, 210 + yaltitude, black) % Base leg 2
                drawfillbox (97, 240 + yaltitude, 102, 249 + yaltitude, black) % Main Rotor Rectangle
                drawfillbox (25, 218 + yaltitude, 110, 223 + yaltitude, black) % Rotor rectangle
                drawfilloval (100, 248 + yaltitude, 50, 5, icolor2) % Rotor Blades
                drawfilloval (100, 220 + yaltitude, 30, 20, black) % Cockpit
                drawfillbox (24, 215 + yaltitude, 27, 238 + yaltitude, black) % Rotor rectangle
                drawfilloval (24, 223 + yaltitude, 10, 10, icolor2) % Rear Rotor Blades
                drawfilloval (75, 220 + yaltitude, 15, 10, black) % Smaller circle from main body of helicopter
                View.Update

                icolor2 := icolor2 + 1

                mousewhere (mx, my, btn)
                if btn = 1 then
                    yaltitude += 1
                else
                    yaltitude -= 1
                end if
                if icolor2 = 31 then
                    icolor2 := 21
                end if

                if whatdotcolor (125, 192 + yaltitude) = white then
                    exit
                end if

                if whatdotcolor (150, 253 + yaltitude) = white then
                    exit
                end if

                delay (3)
            end loop
        end if

        if whatdotcolor (125, 192 + yaltitude) = white then
            exit
        end if
        %%% End Background %%%

       




        % If Controls selected
        if xmouse > 270 and xmouse < 390 and ymouse > 100 and ymouse < 150 and button = 1 then
            Draw.Cls
            View.Update

            loop
                drawfillbox (0, 0, maxx, maxy, 100)

                % Cloud 1
                drawfilloval (90, 350, 130, 80, white)
                drawfilloval (70, 280, 80, 40, white)
                drawfilloval (200, 310, 60, 50, white)
                drawfilloval (230, 380, 60, 50, white)

                % Cloud 2
                drawfilloval (400, 150, 130, 80, white)
                drawfilloval (380, 80, 80, 40, white)
                drawfilloval (410, 220, 80, 40, white)
                drawfilloval (520, 110, 70, 50, white)
                drawfilloval (520, 190, 80, 50, white)
                drawfilloval (300, 180, 60, 50, white)
                drawfilloval (300, 120, 40, 30, white)
                Draw.Text ("Controls", 265, 335, font1, black)
                Draw.Text ("Press B to go Back", 15, 360, font2, black)
                Draw.Text ("Welcome to Super-Heli, the classic game that never gets boring!", 70, 285, font2, black)
                Draw.Text ("The controls of this game are basic, to raise your helicopter,", 80, 255, font2, black)
                Draw.Text ("simply click your mouse to ascend your helicopter vertically,", 77, 225, font2, black)
                Draw.Text ("to descend your helicopter, let go of the mouse button.", 100, 195, font2, black)
                Draw.Text ("But be careful don't touch the white sections or its game over!", 70, 165, font2, black)
                Draw.Text ("Good luck and have fun!", 230, 125, font2, black)
                Draw.Text ("Trademark to the IGC (International Gaming Corporation) Do not copy this game.", 115, 15, font3, black)

                View.Update
                getch (ch)
                if ch = "b" then
                    exit
                else
                end if

            end loop


        else
        end if


        %drawfillbox (290,170,370,220,41)
        %drawfillbox (270,100,390,150,41)




        icolor := icolor + 1
        if icolor = 62 then
            icolor := 1
        end if
        icolor2 := icolor2 + 1
        if icolor2 = 31 then
            icolor2 := 21
        end if
        iXposition := iXposition + xdirection
        iYposition := iYposition + ydirection

        if iXposition > 455 or iXposition < 0 then
            xdirection := -xdirection
        end if

        if iYposition > 215 or iYposition < 0 then
            ydirection := -ydirection
        end if


        %delay (5)
        View.Update

    end loop
    cls
    put "gameover, you can make a better screen lol"
    View.Update
    delay (1000)
end loop


Author:  Conrad13 [ Thu Jan 12, 2012 3:57 pm ]
Post subject:  RE:Helicopter Game Help

OMG!! Thank you is there any way I could make the random squares in the game that you must dodge, like make them not be so small at times, like sometimes they are so small you can not even see them, or sometimes they are to big for the helicopter to even pass how do i set restrictions? or limits to how big or small the boxes can be?

Author:  Alex C. [ Thu Jan 12, 2012 4:10 pm ]
Post subject:  RE:Helicopter Game Help

i'm sorry, i don't really know how to do that but i think you have to use randint to set the location of the random squares

Author:  Conrad13 [ Thu Jan 12, 2012 4:20 pm ]
Post subject:  RE:Helicopter Game Help

Alright thanks anyone else?

Author:  Beastinonyou [ Thu Jan 12, 2012 5:30 pm ]
Post subject:  Re: Helicopter Game Help

a Simple way of having multiple different sizes of rectangles, is to store the Possible Sizes in an array... Let me give a little example

Turing:


type OData :
    record
        x, y, x2, y2, Color, size : int   % Expanding Aange10's example
    end record


var obsticles : array 0 .. 30 of OData

% 10 different sizes of objects (lengths vertically)
var objSizes : array 1 .. 10 of int := init (5, 10, 20, 30, 40, 50, 60, 70, 80, 100)

% later on, when placing the objects

var size : int := 0

randint (size, 1, 10) % Random number

% Set size of the obstacle to a randomly generated object size
obsticles(Obstacle).size := objSizes (size)

% Later, when you draw the obstacle, using it's size, it would be like, y2 = y1 + size


Author:  Conrad13 [ Thu Jan 12, 2012 6:39 pm ]
Post subject:  RE:Helicopter Game Help

ahh thanks but i got no luck with arrays need this done by tomorrow so thanks but i think I will have to tweak it myself some more and throw in the towel : /


: