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

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




PostPosted: Thu Apr 09, 2009 9:14 am   Post subject: Help Please

I am making a game where i need to make characters go down the screen and I need to push a button before the character hits the bottom of the screen, I have done the characters going down the screen but have no put in any commands for buttons I need help with this please help me

This is my program it is in Turing by the way

Turing:

setscreen ("graphics")

procedure Monsta
    var Monsta : int := Pic.FileNew ("Monsta.bmp")
    for y : 200 .. 600
        Pic.Draw (Monsta, 250, (maxx - y), 0)
        delay (10)
        cls
    end for
end Monsta

procedure Witch
    var Witch : int := Pic.FileNew ("Witch.jpg")
    for y : 200 .. 600
        Pic.Draw (Witch, 250, (maxx - y), 0)
        delay (10)
        cls
    end for
end Witch

procedure ghost
    var ghost : int := Pic.FileNew ("ghost.jpg")
    for y : 200 .. 600
        Pic.Draw (ghost, 250, (maxx - y), 0)
        delay (10)
        cls
    end for
end ghost

loop
    locatexy (50, 75)
    put "Do you want to play this Game?(y or n):" ..
    var reply : string
    get reply
    if reply = "n" then
        exit
    elsif reply = "y" then
        cls
        locatexy (50, 75)
    end if
    put "Choose your difficulty(Easy, Moderate, Hard):" ..
    var reply2 : string
    get reply2
    cls
    exit when reply2 not= "yes"
    var Easy : string
    var Moderate : string
    var Hard : string
end loop
loop
    Monsta
    Witch
    ghost
end loop


MODEDIT Remeber your syntax tags!!
code:
[syntax="Turing"]your code here[/syntax]
Sponsor
Sponsor
Sponsor
sponsor
DemonWasp




PostPosted: Thu Apr 09, 2009 10:35 am   Post subject: RE:Help Please

The easiest (and safest) way to design a game is pretty simple. You've sort of got it in your code already. The basic idea is that you will have a game "tick". At every tick, you update the game, then redraw it. On each update, you look for user input, determine what each creature does, move them, attack, whatever. Drawing is simple enough, but has a wrinkle: we'll set it up so that instead of updating the screen after every draw command, you do all the draw commands, then update the screen once. This helps to cut down on flickering.

It looks like this:

Turing:

% Sample storage here. You can feel free to change this as you will.
var monsterY, witchY, ghostY : int := maxy
var monsterPic : int := Pic.FileNew ( "monsta.bmp" )
% do the same for witch and ghost

% Set all of our draw commands to go to a "buffer". Once we've drawn an entire scene for that tick, we'll send it to the screen with View.Update().
View.Set ( "offscreenonly" )

var keys : array char of boolean  % We'll use this for input. See Input.KeyDown() in the Turing help.

loop
    Input.KeyDown ( keys )  % Get input from the player here

    % UPDATE everything here.
    monsterY -= 5
    witchY -= 5
    ghostY -= 5
    if keys ( ' ' ) then
        % Spacebar is down, do whatever spacebar is supposed to do
    end if

    if keys ( KEY_ESC ) then
        % Escape was pressed, quit the game
        exit
    end if

    % DRAW everything here
    Draw.Cls()  % Clear the screen
    Pic.Draw (monsterPic, 250, monsterY, 0)
    % You can fill in the other ones
    View.Update()  % Put our newly-drawn scene onto the screen.
end loop

put "Game Over"
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  [ 2 Posts ]
Jump to:   


Style:  
Search: