Computer Science Canada Almost done...except for one thing! |
Author: | ziggy2shoes [ Thu Nov 23, 2006 10:08 pm ] |
Post subject: | Almost done...except for one thing! |
Alrighty. I've been working on my Turing large program for school and I got most of it all done, it's one of those games where you're a ship and the submarines travel underneath you and you gotta drop the depth charges and destroy them, but, I'm having an extremely hard time trying to figure out how to make the ship drop the depth charges! I would really appreciate it if you could in anyway help me, big or small. Here's my code: Quote: /*
BBBBBB L OOOOOO OOOOOO DDDD W W AAAAAA K K EEEEEE B B L O O O O D D W W A A K K E BBBBBB L O O O O D D W W W AAAAAA KK EEEEEE B B L O O O O D D W W W W A A K K E BBBBBB LLLLLL OOOOOO OOOOOO DDDD WW WW A A K K EEEEEE ____________________________________________________________________________ B Y : J O S H W I L L I A M S B L O O D W A K E (c) 2006 Purpose: This game is for entertainment purposes only. It is a basic ship vs. submarine (U-Boat) game. The player is commandeering the ship and must drop depth charges to destroy enemy nazi U-boats. Controls: The Player uses "a" to go left and "d" to go right. Spacebar is used to drop the depth charges. Object: The object of the game is to destroy as many subs as you can. If 5 subs reach the other side of the screen the convoy you're defending is destroyed and you lose. %---------------------------------------------------------------------------- */ %*************************** %* * %* SETSCREEN #1 * %* * %*************************** % setscreen command setscreen ("graphics:max;max,title:Blood Wake") % background colorback (black) cls %*************************** %* * %*SHIP w/ RED WAKE (title) * %* * %*************************** % title ship intro var introboat := Pic.FileNew ("destroyerB.bmp") for xx : -150..1200 Pic.Draw (introboat, xx, 300, picMerge) drawline (xx, 305, xx, 330, brightred) delay (5) end for %*************************** %* * %* BLOODWAKE TITLE * %* * %*************************** % blood wake title var font1 : int := Font.New ("arial:18") %to do: make an array var font2 : int := Font.New ("arial:18") var font3 : int := Font.New ("arial:18") var font4 : int := Font.New ("arial:18") var font5 : int := Font.New ("arial:18") var font6 : int := Font.New ("arial:18") var font7 : int := Font.New ("arial:18") var font8 : int := Font.New ("arial:18") var font9 : int := Font.New ("arial:18") var font10 : int := Font.New ("arial:18") Font.Draw (" B ", 360, 310, font1, black) delay (300) Font.Draw (" L ", 380, 310, font2, black) delay (300) Font.Draw (" O ", 395, 310, font3, black) delay (300) Font.Draw (" O ", 420, 310, font4, black) delay (300) Font.Draw (" D ", 440, 310, font5, black) delay (300) Font.Draw (" ", 460, 310, font6, black) delay (300) Font.Draw (" W ", 477, 310, font7, black) delay (300) Font.Draw (" A ", 503, 310, font8, black) delay (300) Font.Draw (" K ", 520, 310, font9, black) delay (300) Font.Draw (" E ", 540, 310, font10, black) delay (1000) cls %*************************** %* * %* PRESS ANY KEY * %* * %*************************** proc presskey % anykey to continue color (white) var anykey : int := Font.New ("arial:32") Font.Draw ("Press any key to continue...", 255, 310, anykey, brightred) % anykey prompt loop exit when hasch end loop end presskey presskey %*************************** %* * %* GAMEPLAY * %* movement * %* * %*************************** % movement variables var x, y, spd, check : int % var for input.keydown (key) var key : array char of boolean % player picture variable var player1 := Pic.FileNew ("destroyer.bmp") % ship pic % setscreen & background setscreen ("graphics:max;max,title:Blood Wake,offscreenonly") colorback (76) cls %sets variables x and y x := 10 y := 50 %the ship, water, and sun procedure drawship % ship Pic.Draw (player1, x, y + 323, 2) end drawship proc drawenviro % water drawfillbox (0,0,maxx,375,33) % sun drawfilloval (875,600,20,20,yellow) end drawenviro %draw procedure (ship + bottom line) drawship drawenviro %var check = how high the ship can go (0) check := 0 %var spd = gravity force (0) spd := 0 loop View.Update %sets key as var for key pressed Input.KeyDown (key) %check is preset to 0 if check = 0 then end if %Moves Horizontally %d is pressed if key ('d') then %moves ship 5 to the right x := x + 5 %a is pressed elsif key ('a') then %moves ship 5 to the left x := x - 5 end if delay (50) cls drawship drawenviro end loop I think this is where I should begin but I'm not sure Quote: proc shoot
if key (' ') then % ??????? end if end shoot |
Author: | ericfourfour [ Thu Nov 23, 2006 10:30 pm ] |
Post subject: | |
I would start by indenting your code. |
Author: | NikG [ Thu Nov 23, 2006 10:45 pm ] | ||
Post subject: | |||
ericfourfour, that's a pretty useless comment! Even without indenting, ziggy2shoes is spaced out enough to be pretty clear. ziggy, you're a LONG way away from completion... I don't know how you can say you got most of it done... most of your code is just the intro and setup. In terms of dropping the charges, think about what you need. You already have variables for where your ship is, all you need now are variables for the charges. Everytime space is pressed, you set the intial position of the charge to the ship's position and then do your work. ziggy2shoes wrote:
I suggest looking at the Turing Walkthrough (sorry, link not provided... just go to the Tutorials page). In particular, I think arrays will help you for multiple charges and ships. Good luck. |
Author: | NikG [ Thu Nov 23, 2006 10:48 pm ] |
Post subject: | |
Sorry for the double post. NikG wrote: ziggy2shoes is spaced out enough to be pretty clear. should be "ziggy2shoe's code is spaced out enough to be pretty clear."
Ignore the comment about not providing a link to the Turing Walkthrough... apparently this forum automatically turns that into a link. Very cool Dan! |
Author: | ziggy2shoes [ Thu Nov 23, 2006 10:55 pm ] |
Post subject: | |
Good stuff man! You're right, now that I think of it I got a long way to go. It looks like arrays are good for what I need. I better get cracking! ![]() |
Author: | wtd [ Fri Nov 24, 2006 1:08 am ] | ||
Post subject: | |||
So stop talking about doing it and do it! ![]() Why take the time to do it the long way if you apparently know the better solution? ![]() |
Author: | Clayton [ Fri Nov 24, 2006 7:46 am ] | ||
Post subject: | |||
err, why have all of those fonts when they all have exactly the same thing inside of them? |
Author: | KevinW [ Fri Nov 24, 2006 3:39 pm ] |
Post subject: | |
guess he's making an array with them? |