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

Username:   Password: 
 RegisterRegister   
 help with an intro screen
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
babesjersey4




PostPosted: Sat Jun 04, 2005 10:12 am   Post subject: help with an intro screen

I am creating a game that runs the intro screen has an Input.Pause and then starts the game, the only problem is the background of the intro screen does not clear completely, I have used cls and have reset the background, yet it still does not work, is their anything else I can do?
Sponsor
Sponsor
Sponsor
sponsor
syphon4




PostPosted: Sat Jun 04, 2005 11:13 am   Post subject: screen

try drawing a plain white screen over top of the starting one......

code:
drawfillbox (0, 0, maxx, maxy, 0)
lyam_kaskade




PostPosted: Sat Jun 04, 2005 9:28 pm   Post subject: (No subject)

If you've used cls, there might be a problem with your code. I recommend posting it.
babesjersey4




PostPosted: Sat Jun 04, 2005 10:15 pm   Post subject: (No subject)

code:

View.Set ("noecho,nocursor")
setscreen ("graphics")

% Set constants = ord value of the arrow keys
const RIGHT := 205
const LEFT := 203
const SHOOT := 32
const MAXMENGROUND := 3

var menground := 0     %counts how many men are on the ground
var score := 0 % keeps track of score
var groundCount := 0 %how many parachutters are on the ground
var gunnerHit := false %gunner has not been hit
var gameOver := false %player is still alive

%shot is off the screen to avoid collision with parachute dude
var bulletX, bulletY := -100
var shooting := false %the ship is not firing

%default ship position
var gunnerX := maxx div 2
var gunnerY := 15

var parachuters := 0 % how many parachutes are dropping


Draw.FillBox (0, 0, maxx, maxy, black)
colour (black)
Text.ColorBack (white)
cls

%When a parachuter is hit, have him bleed
procedure paraHit (x, y : int)

    var blood : int := Pic.FileNew ("blood.jpg")     %load the picture

    Pic.Draw (blood, x, y, picCopy)       % draw blood

    delay (1000)

    drawfillbox (x, y, x + 45, y + 50, white) %erase the blood

end paraHit


process introscreen

        const Y := 100 %number for delay
        const X := 1000 %number for delay
       
        Draw.FillBox (0, 0, maxx, maxy, black)
        colour (white)
        Text.ColorBack (black)

        delay (Y)
        locate (5, 35)
        put "W" ..
        delay (Y)
        put "E" ..
        delay (Y)
        put "L" ..
        delay (Y)
        put "C" ..
        delay (Y)
        put "O" ..
        delay (Y)
        put "M" ..
        delay (Y)
        put "E" ..
        locate (7, 25)
        locate (8, 33)
        put "The situation: "
        locate (9, 22)
        put "Enemy parachuters are dropping from the sky."
        delay (X)

        locate (11, 33)
        put "Your mission: "
        locate (12, 22)
        put "Shoot as many parachuters as possible. If they"
        locate (13, 22)
        put "get as many as three men on the ground, it's"
        locate (14, 22)
        put "Game Over for us."

        delay (X)
        locate (16, 22)
        put "Good luck, and may we triumph for all things"
        locate (17, 22)
        put "good!"
        locate (19, 30)
        put "Press the space bar to continue."
        cls

       
end introscreen

process men

    var para : int := Pic.FileNew ("men.jpg")      %load the picture
    % controls a single parachuter which flies down from top of screen
    var menXSpeed := 0
    var menYSpeed := Rand.Int (1, 3)
    var men_Y : int := 0 %stores position of men on Y axis
    parachuters += 1    %increase the number of parachuters
    var menX := Rand.Int (15, 585)


    for decreasing menY : 385 .. 15 by menYSpeed

        Pic.Draw (para, menX, menY, picCopy) %draw the parachuter
        delay (20)
        drawfillbox (menX, menY, menX + 50, menY + 50, black)
        men_Y := menY
        exit when gameOver

        % check if parachuters is on the ground
        if men_Y <= 50 then
            menground += 1
            exit
        end if

        % check if parachuters has been hit by a shot
        if abs (menX - bulletX) < 30 and abs (menY - bulletY) < 30 then
            paraHit (menX, menY)
            score += 100 % adds 100 to score when bullet hits man
            shooting := false
            exit when gameOver
            exit

        end if
    end for
    parachuters -= 1

end men


process clouds
    var cloud : int := Pic.FileNew ("cloud.jpg") % load picture
    var cloudY := 300

    for cloudX : 15 .. 625
        Pic.Draw (cloud, cloudX, cloudY, picCopy)
        Draw.FillBox (cloudX, cloudY, cloudX + 70, cloudY + 70, white)
    end for

end clouds

process moremen         %makes 1-5 men come down randomly

    loop
        if parachuters <= 2 then
            fork men
            % don't let more than 3 on at a time
        else
            delay (100)
        end if
        delay (100)
        exit when gameOver
    end loop

end moremen

%The ship fires
process fire (xc : int)

    shooting := true     % a shot is being fired

    var shot : int := Pic.FileNew ("shot.jpg")     %load the picture

    bulletX := xc     %set the position of the bullet to be aligned with gunner

    % fire the bullet
    for y : gunnerY + 55 .. 385 by 5     %start shot from gunner's position to the top of the screen
        exit when gameOver
        exit when not shooting

        bulletY := y
        Pic.Draw (shot, bulletX, bulletY, picCopy)            % draw the shot
        delay (5)
        Draw.FillBox (bulletX, bulletY, bulletX + 5, bulletY + 22, black)     %erase the shot
    end for

    % move the bullet off the screen so no men can "bump into it"
    bulletX := -100
    bulletY := -100

    shooting := false

end fire

process showScore
    Draw.FillBox (0, 0, maxx, maxy, white)
    % displays score and remaining lives at top of screen
    loop
        % wipe out old score and display current score
        Draw.FillBox (0, maxy - 100, maxx, maxy, white)
        put "Score : ", score
        locate (1, 5)
        put "Men on ground : ", menground
        locate (2, 5)
        % Control when the game is actually over
        if menground = 3 then
            gameOver := true
        end if

        delay (250)

    end loop

end showScore

%draws and moves the gunner
process gunner
    var keyPress : string (1)

    var gunner : int := Pic.FileNew ("gunner.jpg")     %load the picture

    Pic.Draw (gunner, gunnerX, gunnerY, picCopy)     %draw the picture to the screen

    % flush any characters typed but not read yet
    % this keeps ship from jumping away from starting
    % point immediately when it appears
    loop
        exit when not hasch
        getch (keyPress)     % Discard this character
    end loop


    loop
        getch (keyPress)

        % erase the ship at current location before moving
        Draw.FillBox (gunnerX, gunnerY, gunnerX + 50, gunnerY + 50, black)

        % If user pressed an arrow key, move gunner
        if ord (keyPress) = RIGHT and gunnerX < maxx - 15 then
            gunnerX += 25
        elsif ord (keyPress) = LEFT and gunnerX > 15 then
            gunnerX -= 25
        elsif ord (keyPress) = SHOOT and shooting = false then
            fork fire (gunnerX + 19)
            exit when gameOver
        end if
        exit when gameOver
        Pic.Draw (gunner, gunnerX, gunnerY, picCopy)     %draw the ship
    end loop
end gunner



%main program
% fork clouds

fork introscreen
Input.Pause

cls
View.Update

 colorback (black)
Draw.FillBox (0, 0, maxx, maxy, black)
colour (white)
score := 0
menground := 0

fork showScore
fork moremen
fork gunner

if groundCount = MAXMENGROUND then
    cls
    gameOver := true
    put "Game Over"
end if



the intro is cheesy but i just want it to work before i brush it up



blood.jpg
 Description:
 Filesize:  1.52 KB
 Viewed:  2388 Time(s)

blood.jpg



men.jpg
 Description:
 Filesize:  1.68 KB
 Viewed:  2387 Time(s)

men.jpg



shot.jpg
 Description:
 Filesize:  637 Bytes
 Viewed:  2387 Time(s)

shot.jpg



gunner.jpg
 Description:
 Filesize:  1.46 KB
 Viewed:  2388 Time(s)

gunner.jpg


MysticVegeta




PostPosted: Sun Jun 05, 2005 7:00 am   Post subject: (No subject)

OMG! worst use of processes i have seen, except there were these 2 times but nevermind. The processes are screwing up your cls problem, Why dont you use procedures and try looping them?
babesjersey4




PostPosted: Sun Jun 05, 2005 9:02 am   Post subject: (No subject)

ok, i'll do that, thanks so much for the advice
MysticVegeta




PostPosted: Sun Jun 05, 2005 10:09 am   Post subject: (No subject)

Try to minimize your process use just for bg music. But now you dont even need process for that, because the built-in function of turing 4.0.5
code:
Music.PlayFileLoop

So use of processes is now really "0"
Cervantes




PostPosted: Sun Jun 05, 2005 10:20 am   Post subject: (No subject)

MysticVegeta wrote:

So use of processes is now really "0"

Much as I hate the way processes are usually used, I have to disagree with you there. Mckenzie mentioned somewhere sometime ago, processes are just misused. For things such as, in a game of chess, computer AI while waiting for the user's input, processes can be a good thing.
But note: the two processes occuring in this type of program do not affect one another. The computer is searching for the best possible move, but that does not affect the code that waits for user input. Likewise, the code that waits for user input does not affect the search for the best possible move(s). Also, this kind of thing cannot really be done without processes. Say your AI uses a particular procedure and lots of recursion. You could not stick that in the same loop as the input loop because the recursion would take quite some time, so the input would not actually be allowed for most of the time. (Plus, you don't want to loop your AI checking!)
So, for something like AI for chess, processes may be a good thing. But yes, almost every process used in the Turing section here is misused.
Sponsor
Sponsor
Sponsor
sponsor
MysticVegeta




PostPosted: Sun Jun 05, 2005 1:36 pm   Post subject: (No subject)

Just a question Cervantes, how much knowledge and practise and work does it take to program a successful chess game with normal level of AI?
Cervantes




PostPosted: Sun Jun 05, 2005 3:35 pm   Post subject: (No subject)

Well, I've never done it myself, but I would say the hardest part would be the AI, for which you'd probably need a strong background in recursion.
Plus, you have to be good at chess. Smile
c0bra54




PostPosted: Sun Jun 05, 2005 3:55 pm   Post subject: (No subject)

yeh.. AI = ew.. however tic tac toe AI = easy.. and checkers i'msure wouldn't be TO hard.... ust chess, you can't program for possible outcomes.. you need to program.. like.. thinking Razz
[Gandalf]




PostPosted: Sun Jun 05, 2005 4:29 pm   Post subject: (No subject)

For chess you use game tree's. You don't program all the possible outcomes, but the program has to calculate the moves. Since there are LOTS of possible moves in chess, to get a good depth search you don't look at all the possibilities, just the likely ones. There are many strategies of making more complex ai's, and Turing is not the best language for it.

Yeah... so, it would be nice to have a chess program from Turing. It would probably be slow and all, but it would still be great to have some kind of ai. Somebody did a start once. I remember you could do all the moves and everything, but there was no ai or checkmate/special moves/rules.
MysticVegeta




PostPosted: Sun Jun 05, 2005 6:42 pm   Post subject: (No subject)

well i think one of the points that Cervantes mentioned was pretty good - you have to be good at chess. Thats a good point, i think when Gandalf said "special moves", we need to figure out the special moves first in order to program them, and then check for conditions like - the computer doesnt get beaten up first, the computer still will have place to move, the computer has place to move, etc. Congratz we have programmed 1/100th piece of AI required for normal level chess Blowing up Blowing up
[Gandalf]




PostPosted: Sun Jun 05, 2005 7:08 pm   Post subject: (No subject)

Yeah, you have to be decent in chess, true. What I meant with "special moves" was like en passant and castle...

For a lot of opening moves and endgame moves there are things called "opening books" and "endgame databases" that just have a bunch of different scenarios for around 4-12 moves so that the beginnings go fast and according to predefined strategies.

In the middle, main game where the computer is calculating, it doesn't have to find a "good move". What it usually does is put a value on the different positionings and pieces then try and find a combination of moves which gain it that advantage.

I spent a lot of time on chess programming, that's what really introduced my to programming, and I was doing this stuff even before I knew how to program.
c0bra54




PostPosted: Sun Jun 05, 2005 7:46 pm   Post subject: (No subject)

aaa lol.. i think compsci should like.. try it.. everyone here , like have people, make 3D models, and just render as pictures... and have boards, and everything, and have like a 3 person team on how to make AI research it an everything.. i think this could be pretty crazy...


also about pocess's during the opponent (player's) move.. wouldn't that not work right, since the compter wouldn't be taking into account, the move that the player is making.. since if it decided on it's move, before the player moved, then the computer moved.. wouldn't it never take the last move into event.. so wouldn't it be like.. really REALLY easy computer.. since if you put it into check, it doens't know that Razz so it'll just lose...???
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 2  [ 21 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: