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

Username:   Password: 
 RegisterRegister   
 Desperate Help! Turing Project Grade 10
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
doow




PostPosted: Tue Jan 20, 2009 8:22 pm   Post subject: Desperate Help! Turing Project Grade 10

I have to create a program that is controlled by a joy stick, as of right now, I just want my "snake" to be controlled by the numbers 8,4,5, and 6.
So that I at least have a program that runs...then I'll worry about hooking up my joy stick.
I'm attempting to make the game snake, or at the very least, similar to it.
I'll post what I've got...
Did I mention I'm HORRIBLE at this?
Any help would be greatly appreciated.

This is what I've got...

Turing:
setscreen ("graphics")
var KEY : string (1)
var XPOS, YPOS : int := 300
var XDIR, YDIR : int := 0
var LOSE : int := 0
var SCORE : int := 0
var ss : int := 0
var HARDNESS : int := 0



put "Enter the level of difficulty you wish to play,"
put "    by entering a number between 1 and 5. "
get HARDNESS   
if HARDNESS > 5 then
HARDNESS := 5
elsif HARDNESS <= 0 then
HARDNESS := 1
end if
cls

put "Ready to play Snake?"
put "Object of the game is to move your joystick to guide your snake, "
put "without hitting yourself as you grow."
put "How long can you last? "
Time.Delay (4000)
cls
Draw.Box (0, 0, maxx, maxy, red)
Draw.Box (HARDNESS * 10, HARDNESS * 10, maxx - HARDNESS * 10, maxy - HARDNESS * 10, red)
Draw.Fill (1, 1, red, red)


setscreen ("graphics")
for x:1..500
drawfilloval (x,235,10,10,42)
delay(50)
end for
loop
if hasch then
getch (KEY)
if KEY = "8" then
YDIR := 1
XDIR := 0
ss := 5
elsif KEY = "4" then
YDIR := 0
XDIR := -1
ss := 5
elsif KEY = "5" then
YDIR := -1
XDIR := 0
ss := 5
elsif KEY = "6" then
YDIR := 0
XDIR := 1
ss := 5

end if
KEY := ""
end if


XPOS := XPOS + XDIR
YPOS := YPOS + YDIR
Draw.FillOval (XPOS, YPOS, 5, 5, red) 
Time.Delay (8)         
Draw.FillOval (XPOS, YPOS, 5, 5, red)


if XDIR = 1 and whatdotcolor (XPOS + 6, YPOS) = purple then
LOSE := LOSE + 1
elsif XDIR = -1 and whatdotcolor (XPOS - 6, YPOS) = yellow then
LOSE := LOSE + 1
elsif YDIR = 1 and whatdotcolor (XPOS, YPOS + 6) = red then
LOSE := LOSE + 1
elsif YDIR = -1 and whatdotcolor (XPOS, YPOS - 6) = green then
LOSE := LOSE + 1

end if
if ss = 5 then
SCORE := SCORE + 1
end if

exit when LOSE = 1
end loop
cls
put "Sorry, Game Over!"
put " "
put "Your score was: ", SCORE
put " "
if SCORE <= 500 then
put "You need some practise!"
elsif SCORE <= 1500 then
put "I know you can do better than that!"
elsif SCORE > 1000 and SCORE <= 3500 then
put "Not bad."
elsif SCORE > 3000 and SCORE <= 5500 then
put "Woo, that was a good run."
elsif SCORE > 5000 and SCORE <= 8500 then
put "Yay! Good job."
elsif SCORE > 8000 and SCORE <= 11500 then
put "Excellent!"
elsif SCORE > 11000 then
put "You're the snake CHAMP!"
end if


Mod Edit: Remember to use syntax tags! Thanks Smile
code:
[syntax="turing"]Code Here[/syntax]
Sponsor
Sponsor
Sponsor
sponsor
Saad




PostPosted: Tue Jan 20, 2009 9:23 pm   Post subject: Re: Desperate Help! Turing Project Grade 10

Tip, when stealing code
A) Don't do it from this site
B) Small amount of changes doesn't cover the fact its stolen
C) Don't bother stealing it

Original Post: http://compsci.ca/v3/viewtopic.php?t=17485&highlight=elsif+score+score

Have fun submitting your code to your teacher. He/she is bound to know based on what you've done so far that your code is stolen.

Also I recommend people to read "How to Spot Plagiarized Code" By Tony.


This thread is locked
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: