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

Username:   Password: 
 RegisterRegister   
 Typing Game [Having Difficulties]
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
penny2199




PostPosted: Fri Nov 07, 2014 10:16 am   Post subject: Typing Game [Having Difficulties]

Typing Game
<Replace all the <> with your answers/code and remove the <>>


So I'm trying to make a game where random letters fall from the top of the screen and we need to use ord and chr I believe. When the letter falls the user needs to type that letter so that they can earn a point and the next random letter falls. Im not sure how to do it though.
<Answer Here>


I understand what ord and char is but Im not sure how to make it work in this sort of program.
<Answer Here>


A relevant code
<Answer Here>

Turing:


< var myFont : int := Font.New ("sans serif:18:bold")
   Font.Draw ("Turing!", 239, 239, myFont, blue) >



Turing
<Answer Here>
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Fri Nov 07, 2014 2:16 pm   Post subject: RE:Typing Game [Having Difficulties]

What is "it" that you are unsure about? What is your guess -- you must have some ideas about some of the parts (at the very least that some parts are involved).

To me, CS classes are unique in regards of "not sure". In English class, if you are not sure if you are interpreting a passage correctly or if you are not sure if you are expressing yourself clearly, you'd typically have to wait (a long time) to ask someone (are you sure that _they_ are sure?).

In CS, that someone is your own computer -- it doesn't judge, you can ask as often as you'd like, and it's fast. This computer is your permission to fail (you learn things that don't work) and try your next approach.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
penny2199




PostPosted: Fri Nov 07, 2014 5:25 pm   Post subject: RE:Typing Game [Having Difficulties]

How do I make random letters appear, and have the user type the letter shown and have the next letter appear.
Tony




PostPosted: Fri Nov 07, 2014 6:16 pm   Post subject: RE:Typing Game [Having Difficulties]

That's a much better question! Something to notice is that as you are getting details and structure to ask such a question, you are starting to develop a layout for your program. We can start to flesh out some of those ideas by consulting http://compsci.ca/holtsoft/doc/ for documentation of what Turing can do.

random -- Rand.Int will give us a random number.
(random) letters -- we need some way to translate numbers into letters. You've already mentioned chr and documentation might give additional examples
appear -- you already have an example of using Font.Draw above.
user type the letter -- IO operations that deal with a single letter are hasch and getch
next letter appear -- sounds like a loop might be appropriate here, and Turing Walkthrough has links to tutorials to review.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
penny2199




PostPosted: Tue Nov 11, 2014 11:04 am   Post subject: Re: Typing Game [Having Difficulties]

Sad Sad
I'm getting errors in my code and I don't know what to do or how to fix it.
Sad Sad


var myFont : int := Font.New ("sans serif:18:bold")
var randomLetter: int:= chr(97,124)
var points: int

Font.Draw (randomLetter, 239, 239, myFont, blue)

var key : string (1)
loop
if hasch then
getch (key)
if key = randomLetter then
put points:= 1
Font.Draw (randomLetter, 239, 239, myFont, blue)
elsif key not= randomLetter then
end loop
put "Your score:"
put "= ", points, " "
end if
Tony




PostPosted: Wed Nov 12, 2014 1:13 am   Post subject: RE:Typing Game [Having Difficulties]

Start from the top. What exactly does the error say? What line of code does the error reference?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
penny2199




PostPosted: Mon Nov 17, 2014 10:10 am   Post subject: Re: Typing Game [Having Difficulties]

[/b] Red & Bold indicate errors:



var myFont : int := Font.New ("sans serif:18:bold")
var randomLetter: int:= chr(97[b],
124)
var points: int

Font.Draw (randomLetter, 239, 239, myFont, blue)

var key : string (1)
loop
if hasch then
getch (key)
if key = [b]randomLetter[/b] then
put points:= 1
Font.Draw (randomLetter, 239, 239, myFont, blue)
elsif key not= randomLetter then
end loop
put "Your score:"
put "= ", points, " "
end if[/b]
Tony




PostPosted: Mon Nov 17, 2014 12:35 pm   Post subject: Re: RE:Typing Game [Having Difficulties]

How do you even know that there are errors? The expected answer is that the compiler tells you so, with a specific line number and a specific error message... well then, as asked before:
Tony @ Wed Nov 12, 2014 1:13 am wrote:
What exactly does the error say?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Sponsor
Sponsor
Sponsor
sponsor
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  [ 8 Posts ]
Jump to:   


Style:  
Search: