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

Username:   Password: 
 RegisterRegister   
 MAKING A GAME
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
GOLDEN WEAPON




PostPosted: Wed May 21, 2003 4:26 pm   Post subject: MAKING A GAME

Ok, I am in my first year of programming and my friend and I are way ahead of the class. For our final project we need to make a game with turing. We decided to make a game kind of like and old school space shooter where you shoot at the lines of enemies coming at you from one side of the screen. We started it on the weekend and everything have benn running pretty smoothly except one thing. Whenever we move our jets, the image of the jet at the x,y it was just at stays there once we move and it leavels a trail of the jets behind itself. We tried having a cls after the Input.KeyDown but it makes the screen flash as you play and it takes a few seconds to reload the background each time. So I guess my question is how do I clear the extra jets away without using a cls command?

Mod Edit: How about a better title next time? More poelop will probley help you then and sooner. You are lucky Asok did not locke this Wink
Sponsor
Sponsor
Sponsor
sponsor
Catalyst




PostPosted: Wed May 21, 2003 4:48 pm   Post subject: (No subject)

if u have turing 4 (i think u do since you have (Input.KeysDown)


at the top of ur prog put
View.Set ("offscreenonly")


then in the loop

View.Update
cls
naoki




PostPosted: Wed May 21, 2003 4:58 pm   Post subject: (No subject)

also when using the Pic.Draw or Pic.ScreenLoad commands use picMerge as your method of displaying the picture.

As well, you won't need picXor after loading the image (a mistake of mine early on)

Oh yeah, picMerge only works if your background of your picture is white, so make that happen beforehand.
GOLDEN WEAPON




PostPosted: Wed May 21, 2003 5:06 pm   Post subject: (No subject)

I also have the background image as the Clouds.bmp from windows (some of you might know it). So would it be ok to use picUnderMerge for that image?
GOLDEN WEAPON




PostPosted: Wed May 21, 2003 5:18 pm   Post subject: (No subject)

Ok, it's even worse now. When I start the program, the screen goes totally white. When I try to close the window, it comes up correctly, but when I try to move a jet, the screen goes totally black! HELP!!

code:


var x : int := 100
var y : int := 410
var x2 : int := 100
var y2 : int := 70
var jet1nofire : int
var jet1fire : int
var jet2nofire : int
var jet2fire : int
var Clouds : int
var Clouds2 : int
var Clouds3 : int
var Clouds4 : int
var skywidth, skyheight : int := 0
var skywidth2, skyheight2 : int := 0
var skywidth3, skyheight3 : int := 0
var skywidth4, skyheight4 : int := 0
var skyx, skyy : int := 0
var skyxedge : int := 640
var skyyedge : int := 480
Clouds := Pic.FileNew ("Clouds.bmp")
Clouds2 := Pic.FileNew ("Clouds.bmp")
Clouds2 := Pic.Mirror (Clouds2)
Clouds3 := Pic.FileNew ("Clouds.bmp")
Clouds3 := Pic.Flip (Clouds3)
Clouds4 := Pic.FileNew ("Clouds.bmp")
Clouds4 := Pic.Flip (Clouds4)
Clouds4 := Pic.Mirror (Clouds4)
jet1nofire := Pic.FileNew ("jet1nofire.bmp")
Pic.SetTransparentColour (jet1nofire, white)
jet1fire := Pic.FileNew ("jet1fire.bmp")
Pic.SetTransparentColour (jet1fire, white)
jet2nofire := Pic.FileNew ("jet2nofire.bmp")
Pic.SetTransparentColour (jet2nofire, white)
jet2fire := Pic.FileNew ("jet2fire.bmp")
Pic.SetTransparentColour (jet2fire, white)
var jethealth1 : real := 100
var jethealth2 : real := 100
var score1 : int := 0
var score2 : int := 0
var bullets : int
var bullets2 : int
const uparrow : char := chr (200)
const leftarrow : char := chr (203)
const rightarrow : char := chr (205)
const downarrow : char := chr (208)
const ctrl : char := chr (181)
const w : char := chr (119)
const a : char := chr (97)
const d : char := chr (100)
const s : char := chr (115)
const f : char := chr (102)
var choice : string
var keys : array char of boolean

View.Set ("offscreenonly")
setscreen ("graphics:max;max,noecho,offscreenonly,nocursor,nobuttonbar")

procedure drawscreen
    skywidth := Pic.Width (Clouds)
    skyheight := Pic.Height (Clouds)
    skywidth2 := Pic.Width (Clouds2)
    skyheight2 := Pic.Height (Clouds2)
    skywidth3 := Pic.Width (Clouds3)
    skyheight3 := Pic.Height (Clouds3)
    skywidth4 := Pic.Width (Clouds4)
    skyheight4 := Pic.Height (Clouds4)
    Pic.Draw (Clouds, -skyx, -skyy, picUnderMerge)
    Pic.Draw (Clouds2, skyxedge, -skyy, picUnderMerge)
    Pic.Draw (Clouds3, -skyx, skyyedge, picUnderMerge)
    Pic.Draw (Clouds4, skyxedge, skyyedge, picUnderMerge)
    locate (1, 1)
    put "Player 1:", "" : 2, "Health: ", jethealth1 ..
    put " ", "Score: ", score1
    put "Player 2:", "" : 2, "Health: ", jethealth2 ..
    put " ", "Score: ", score2
end drawscreen

colourback (black)
colour (brightred)

drawscreen
colourback (black)
colour (brightred)

Pic.Draw (jet1nofire, x, y, picMerge)
Pic.Draw (jet2nofire, x2, y2, picMerge)
delay (2000)
loop
    exit when jethealth1 <= 0 and jethealth2 <= 0
    %player 1
    Input.KeyDown (keys)

    if keys (uparrow) then
        y := y + 2
        delay (5)
        cls
        View.Update
        drawscreen
        Pic.Draw (jet1nofire, x, y, picMerge)

    end if
    if keys (downarrow) then
        y := y - 2
        delay (5)
        cls
        View.Update
        drawscreen
        Pic.Draw (jet1nofire, x, y, picMerge)
    end if
    if keys (rightarrow) then
        x := x + 4
        delay (5)
        cls
        View.Update
        drawscreen
        Pic.Draw (jet1fire, x, y, picMerge)
    end if
    if keys (leftarrow) then
        x := x - 4
        delay (5)
        cls
        View.Update
        drawscreen
        Pic.Draw (jet1nofire, x, y, picMerge)
    end if
    if keys (ctrl) then
        randint (bullets, 1, 5)
        for shot : 1 .. 15
            drawline (x + 22 + shot * 20 + bullets, y + 22, x + 24 + shot * 20 + bullets, y + 22, 12)
            drawline (x + 22 + shot * 20 + bullets, y + 39, x + 24 + shot * 20 + bullets, y + 39, 12)
            drawline (x + 20 + shot * 20 + bullets, y + 22, x + 23 + shot * 20 + bullets, y + 22, 15)
            drawline (x + 20 + shot * 20 + bullets, y + 39, x + 23 + shot * 20 + bullets, y + 39, 15)
            delay (5)
        end for
        cls
        View.Update
        drawscreen

    end if
    %player 2

    if keys (w) then
        y2 := y2 + 2
        delay (5)
        cls
        View.Update
        drawscreen
        Pic.Draw (jet2nofire, x2, y2, picMerge)
    end if
    if keys (s) then
        y2 := y2 - 2
        delay (5)
        cls
        View.Update
        drawscreen
        Pic.Draw (jet2nofire, x2, y2, picMerge)
    end if
    if keys (d) then
        x2 := x2 + 4
        delay (5)
        cls
        View.Update
        drawscreen
        Pic.Draw (jet2fire, x2, y2, picMerge)
    end if
    if keys (a) then
        x2 := x2 - 4
        delay (5)
        cls
        View.Update
        drawscreen
        Pic.Draw (jet2nofire, x2, y2, picMerge)
    end if
    if keys (f) then
        randint (bullets2, 1, 5)
        for shot2 : 1 .. 15
            drawline (x2 + 22 + shot2 * 20 + bullets2, y2 + 23, x2 + 24 + shot2 * 20 + bullets2, y2 + 23, 12)
            drawline (x2 + 22 + shot2 * 20 + bullets2, y2 + 41, x2 + 24 + shot2 * 20 + bullets2, y2 + 41, 12)
            drawline (x2 + 20 + shot2 * 20 + bullets2, y2 + 23, x2 + 23 + shot2 * 20 + bullets2, y2 + 23, 15)
            drawline (x2 + 20 + shot2 * 20 + bullets2, y2 + 41, x2 + 23 + shot2 * 20 + bullets2, y2 + 41, 15)
            delay (5)
        end for
        cls
        View.Update
        drawscreen
    end if
end loop
cls
put "Game Over"


arg

o yeah there are some vars etc. that don't seem to be part of it but it's a work in progress so just ignore them
kythoon




PostPosted: Wed May 21, 2003 5:23 pm   Post subject: (No subject)

can u attach pictures so we can see whole thing
GOLDEN WEAPON




PostPosted: Wed May 21, 2003 5:36 pm   Post subject: (No subject)

Here are the pics. I had to switch them to .jpg so you'll have to edit a bit of code to use them.


jet2nofire.jpg
 Description:
 Filesize:  1.49 KB
 Viewed:  5976 Time(s)

jet2nofire.jpg



jet2fire.jpg
 Description:
 Filesize:  1.69 KB
 Viewed:  5975 Time(s)

jet2fire.jpg



jet1nofire.jpg
 Description:
 Filesize:  1.73 KB
 Viewed:  5974 Time(s)

jet1nofire.jpg



jet1fire.jpg
 Description:
 Filesize:  1.87 KB
 Viewed:  5975 Time(s)

jet1fire.jpg



Clouds.jpg
 Description:
 Filesize:  27.01 KB
 Viewed:  5976 Time(s)

Clouds.jpg


Tony




PostPosted: Wed May 21, 2003 6:31 pm   Post subject: (No subject)

why are pictures loaded as .bmp but files are .jpg?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor
Sponsor
sponsor
Asok




PostPosted: Wed May 21, 2003 6:37 pm   Post subject: (No subject)

you can't upload .bmps for some reason

*blames Dan*

anyways you're better off leaving them in bmp format and putting them into a zip file.
nate




PostPosted: Wed May 21, 2003 7:07 pm   Post subject: zip

Twisted Evil Ur posting stuff on a turing discussion board, if you are doing that i am sure you would have the computer sense to zip your files so we don't become annoyed at repetitive downloading Twisted Evil

* Evil or Very Mad Evil or Very Mad sry if i seem harsh 1500 word essays make you evil Evil or Very Mad Evil or Very Mad *
GOLDEN WEAPON




PostPosted: Thu May 22, 2003 7:58 pm   Post subject: (No subject)

Sorry about that, but I fixed it myself today. Thanks for your help anyway.
Mephi




PostPosted: Fri May 23, 2003 10:31 pm   Post subject: ERm..

if your screen is completely white its probably cuz u didnt put in enuff View.Updates.....
Corpy




PostPosted: Sun May 25, 2003 9:19 pm   Post subject: (No subject)

I did a program like that and what i did was i had to keep the View.Set ("offscreenonly") in a procedure otherwise the same thing happened.
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  [ 13 Posts ]
Jump to:   


Style:  
Search: