Computer Science Canada

Grade 10 Student Needs Help!!!

Author:  BangBangMario [ Sat Dec 28, 2013 11:59 am ]
Post subject:  Grade 10 Student Needs Help!!!

What is it you are trying to achieve?
I don't know what a string is and how to make a procedure


What is the problem you are having?
I want to learn what a string is and how to make a procedure


Describe what you have tried to solve this problem
Tried looking through forums and reading the online textbook but still don't get it


I need to learn this for my final project for the grade 10 computer studies course please help!





Please specify what version of Turing you are using
4.1.1

Author:  Raknarg [ Sat Dec 28, 2013 1:23 pm ]
Post subject:  RE:Grade 10 Student Needs Help!!!

The Turing Walkthrough

A string is like a word. You can make a variable a word. This is different from an int or real, those variables can only be numbers. Like so:

Turing:

var s : string := "This is a string"
var n : int := 126


Noticehow I put quotes around the string. This encapsulates what I want to be in the word.
A procedure is a block of code that you can call using it's name. Like so:

Turing:

procedure print_hello
    put "Hello!"
end print_hello

print_hello


Whenever I cann print_hello, it will do whatever code is inside the procedure. Mostly it saves a lot of time and stops you from repeating code. They can also have things called parameters, which makes the procedure do certain things depending on what is inside them:

Turing:

procedure greet (name : string)
    put "Hello, " name
end greet

greet ("BangBangMario")

Author:  BangBangMario [ Sat Dec 28, 2013 2:25 pm ]
Post subject:  Re: Grade 10 Student Needs Help!!!

oh ok thank you... but what about the more complex procedures and also could also teach me how to do simple animations like move a car? thank you soo much

Author:  Raknarg [ Sat Dec 28, 2013 4:19 pm ]
Post subject:  RE:Grade 10 Student Needs Help!!!

You definitely should have studied more. Have you payed attention in all your classes?

Define more complex.

Animations are pretty simple. Usually you just have something to keep track of position, and then you draw it accordingly. For instance, you can draw a circle going across the screen.

Turing:

for i : 0 .. maxx
    Draw.FillOval (i, maxy div 2, 10, 10, 12) % Draws a red circle across the screen
    cls % This clears the screen so we can start fresh. Otherwise, it will leave a red streak on the screen. Try it without it.
end for

%Alternatively:
var x : int := 0
loop
    exit when x > maxx %Same thing as the for loop, goes from 0 to maxx
    Draw.FillOval (x, maxy div 2, 10, 10, 12) %Same as before, but now we're using a variable that we keep rack of ourselves
    cls
    x := x + 1
end loop

Author:  BangBangMario [ Sat Dec 28, 2013 6:07 pm ]
Post subject:  Re: Grade 10 Student Needs Help!!!

just like the one you posted, could you explain to me every part of it. And i have paid attention just forgot things after we started HTML

Author:  Raknarg [ Sat Dec 28, 2013 8:25 pm ]
Post subject:  RE:Grade 10 Student Needs Help!!!

Alright, sure.

So with a procedure, you define code that will be attached to a specific name. It's kindof like a variable, but instead of attaching a name to a certain value, it's a block of code.

Let's take greet, for example.

Turing:

procedure greet (name : string)
    put "Hello, " name
end greet

greet ("BangBangMario")


First, we put the word procedure. This is like saying var. We're telling the computer that we want the next thing to be a procedure.

Next, we have the procedure name. This tells the computer that whenever you call that name, it will activate the code block attached to that name. If you put greet in the middle of our program, it will do whatever is inside greet.

The next part are parameters. You do not necessarily need any. When you call the procedure, if there's any parameters attached to the name, you need to call that as well. If we look at greet, it has a parameter called name. In the procedure greet, it will have a temporary variable called name that is whatever we assigned it as when we called it.

Then, we put any code we want. Doesn't really matter what it is.

Then we end the procedure with it's name. This says we're done defining what greet is.

Now look what happens when we call greet. It has one parameter in it, so we have to give it one in the program. In this case, the procedure greet will be called and the variable name will be "BangBangMario". Then, according to the procedure, it will put name on the screen.


Any questions?

Author:  BangBangMario [ Sun Dec 29, 2013 5:44 pm ]
Post subject:  Re: Grade 10 Student Needs Help!!!

You are an amazing teacher sir... i understand procedure now and one last thing is if you could explain the animations part... and also there is one part the teacher didnt teach which is how to make a clickable menu and also use the keyboard to make selections.

Author:  Raknarg [ Sun Dec 29, 2013 11:08 pm ]
Post subject:  RE:Grade 10 Student Needs Help!!!

I've spent a lot of time teaching teenagers, I'd hope I'm at least somewhat decent :p thanks.

Think about your animation in terms of frames. Let's look at our ball animation:

Turing:


for i : 0 .. maxx
    Draw.FillOval (i, maxy div 2, 10, 10, 12) % Draws a red circle across the screen
    cls % This clears the screen so we can start fresh. Otherwise, it will leave a red streak on the screen. Try it without it.
end for

%Alternatively:
var x : int := 0
loop
    exit when x > maxx %Same thing as the for loop, goes from 0 to maxx
    Draw.FillOval (x, maxy div 2, 10, 10, 12) %Same as before, but now we're using a variable that we keep rack of ourselves
    cls
    x := x + 1
end loop


Now, what's going on here? To make the illusion that the circle is going across the screen, we have to draw it multiple times at different spots. Remember you can draw things anywhere on the screen.

How do we determine what numbers to put in as the coordinates? Well, for my program, I wanted to make it go from the left side to the right side, through the middle. This means that I will always draw it on the middle of the y axis, (maxy div 2) and then I just have to find some way to move it across the x axis like I want.

This is achieved by theexamples I have up there. In the first case, I have a variable in the for loop that keeps track of the x position. I draw it maxx times, and each time the number gets bigger and bigger. This is how I make it appear to move across.

The second example is actually what you should do. The reason for this is because you may have multiple objects which will animate through different amounts of frames, like this:

Turing:

var x, y : int := 0
loop
    exit when x > maxx
    Draw.FillOval (x, maxy div 2, 10, 10, 12)
    Draw.FillOval (maxx div 2, y, 10, 10, 7)
    delay(5) % note I forgot this before. If it's not included, your program may run too quickly
    cls
    x := x + 1
    y := y + 1
end loop


Clickable menus may be a little more challenging. The simplest thing to do would be to use Turing's GUI module, which I have no idea how to use. You can look it up on the Turing Walkthrough I think

Author:  BangBangMario [ Tue Dec 31, 2013 11:32 am ]
Post subject:  Re: Grade 10 Student Needs Help!!!

Thanks so much... but another problem.....

when i make the button for credits i need anoter page to pop up and then press a letter on the keyboard to go back to the original page... any ideas?

Author:  Raknarg [ Tue Dec 31, 2013 12:46 pm ]
Post subject:  RE:Grade 10 Student Needs Help!!!

You could use states

Turing:

var state : string := "MENU"
loop
    if state = "MENU" then
        do_menu_stuff()
        if startGame.is_clicked() then
            state := "GAME"
        end if
    elsif state = "GAME" then
        do_game_stuff()
        if gameOver() then
            state = "CREDITS"
        end if
    elsif state = "CREDITS" then
        do_credit_stuff()
        if keyboard.is_pressed() then
            state = "MENU"
        end if
    end if
end loop


This just shows logic, it's not real code

Author:  BangBangMario [ Thu Jan 02, 2014 1:06 pm ]
Post subject:  Re: Grade 10 Student Needs Help!!!

drawfillbox (0, 50, 100, 50, 15)
drawfillbox (0, 100, 150, 100, 15)
drawfillbox (0, 150, 200, 150, 15)
drawfillbox (0, 200, 250, 200, 15)
drawfillbox (0, 250, 300, 250, 15)
Draw.ThickLine (50, 0, 50, 50, 10, 7)
Draw.ThickLine (50, 50, 100, 50, 10, 7)
Draw.ThickLine (100, 50, 100, 100, 10, 7)
Draw.ThickLine (100, 100, 150, 100, 10, 7)
Draw.ThickLine (150, 150, 150, 100, 10, 7)
Draw.ThickLine (200, 150, 150, 150, 10, 7)
Draw.ThickLine (200, 200, 200, 150, 10, 7)
Draw.ThickLine (200, 200, 250, 200, 10, 7)
Draw.ThickLine (250, 200, 250, 250, 10, 7)
Draw.ThickLine (250, 250, 300, 250, 10, 7)



the boxes arent appearing on my stairs... any ideas??

Author:  Raknarg [ Thu Jan 02, 2014 1:15 pm ]
Post subject:  RE:Grade 10 Student Needs Help!!!

First of all, remember order matters.

Second: drawfillbox (0, 50, 100, 50, 15)
You realize this just draws a line, right?

Author:  BangBangMario [ Thu Jan 02, 2014 3:18 pm ]
Post subject:  Re: Grade 10 Student Needs Help!!!

myy badd, i switched the x and y values

Author:  BangBangMario [ Fri Jan 03, 2014 7:30 pm ]
Post subject:  Re: Grade 10 Student Needs Help!!!

proc background
%%night sky%%
drawfillbox (0, 0, maxx, maxy, 177)
drawfilloval (100, 575, 75, 75, 92)
drawfilloval (125, 600, 75, 75, 177)

%%Stairs%%
drawfillbox (50, 0, 100, 50, 15)
drawfillbox (100, 0, 150, 100, 15)
drawfillbox (150, 0, 200, 150, 15)
drawfillbox (200, 0, 250, 200, 15)
drawfillbox (250, 0, 300, 250, 15)
drawfillbox (300, 0, 350, 300, 15)
Draw.ThickLine (50, 0, 50, 50, 10, 7)
Draw.ThickLine (50, 50, 100, 50, 10, 7)
Draw.ThickLine (100, 50, 100, 100, 10, 7)
Draw.ThickLine (100, 100, 150, 100, 10, 7)
Draw.ThickLine (150, 150, 150, 100, 10, 7)
Draw.ThickLine (200, 150, 150, 150, 10, 7)
Draw.ThickLine (200, 200, 200, 150, 10, 7)
Draw.ThickLine (200, 200, 250, 200, 10, 7)
Draw.ThickLine (250, 200, 250, 250, 10, 7)
Draw.ThickLine (250, 250, 300, 250, 10, 7)
Draw.ThickLine (300, 250, 300, 300, 10, 7)
Draw.ThickLine (300, 300, 350, 300, 10, 7)
%%house%%
drawfillbox (350, 0, maxx, maxy, 186) %draws the bricks of the house
drawfillbox (500, 300, 700, 500, 20) %the glass of the window
Draw.ThickLine (600, 300, 600, 500, 10, 7) %frame of the window
Draw.ThickLine (500, 400, 700, 400, 10, 7) %frame of the window
drawfillbox (400, 0, 475, 125, 1) %recycling bin
Font.Draw ("RECYCLE", 415, 75, font1, red) %writes recycle on the bin
drawfillbox (525, 0, 600, 125, 21) %garbage bin
Font.Draw ("GARBAGE", 540, 75, font1, red) %write garbage on the garbage bin
drawfilloval (465, 15, 15, 15, 7) %the wheel of the recycling bin
drawfilloval (590, 15, 15, 15, 7) % draws the wheel of the garbage bin
end background

background
setscreen ("offscreenonly")
for y : 350 .. 250 by 2
background
drawfilloval (325, y, 25, 25, 4)
View.Update
delay (25)
end for




nothings animating with the red text[/quote]

Author:  Raknarg [ Fri Jan 03, 2014 10:45 pm ]
Post subject:  RE:Grade 10 Student Needs Help!!!

Turing:

%This goes forward:
for i : 1 .. 5
end for

%this goes backwards:
for decreasing i : 1 .. 5
end for

Author:  BangBangMario [ Sun Jan 05, 2014 10:55 am ]
Post subject:  Re: Grade 10 Student Needs Help!!!

so what am i to take out and where should i add the "i" in and by the way what does the "i" even mean??

Author:  Raknarg [ Sun Jan 05, 2014 11:51 am ]
Post subject:  RE:Grade 10 Student Needs Help!!!

first off I screwed up, it should be:

for decreasing i : 5 .. 1

Second, it doesn't matter what you call it. It can be i, or q, or counter, or flibbertigibbet. You wanted a way to make a for loop that decreased, I showed you how to make one. Try to apply what I showed you to your code.

It's very close. Everything you're doing is right, the syntax is just a little off.

Author:  Raknarg [ Sun Jan 05, 2014 11:51 am ]
Post subject:  RE:Grade 10 Student Needs Help!!!

first off I screwed up, it should be:

for decreasing i : 5 .. 1

Second, it doesn't matter what you call it. It can be i, or q, or counter, or flibbertigibbet. You wanted a way to make a for loop that decreased, I showed you how to make one. Try to apply what I showed you to your code.

It's very close. Everything you're doing is right, the syntax is just a little off.

Author:  BangBangMario [ Sun Jan 05, 2014 12:07 pm ]
Post subject:  Re: Grade 10 Student Needs Help!!!

background
setscreen ("offscreenonly")
for decreasing y : 350 .. 250 by 30
drawfilloval (325, y, 25, 25, 4)
View.Update
delay (25)
end for



this is working now but i cant figure out how to get rid of the trail that is left behind

Author:  BangBangMario [ Sun Jan 05, 2014 12:09 pm ]
Post subject:  Re: Grade 10 Student Needs Help!!!

never mind i got it, i forgot to put my background after the for decreasing y : 350 .. 250 by 2

Author:  BangBangMario [ Sun Jan 05, 2014 12:22 pm ]
Post subject:  Re: Grade 10 Student Needs Help!!!

so now i have encountered another problem, after i got the circle to move down i need it to move to the left and down again about 6 more times and my teacher said to do it strictly with loops... could you help me out?

Author:  Raknarg [ Sun Jan 05, 2014 12:33 pm ]
Post subject:  RE:Grade 10 Student Needs Help!!!

An easier way would be too keep track of the balls position. Consider this:

Turing:

var x, y : int := 200

for rep : 1 .. 4
    for changex : 1 .. 50
        x -= 1
        Draw.FillOval(x, y, 10, 10, 12)
        delay(5)
        cls
    end for
    for changey : 1 .. 50
        y -= 1
        Draw.FillOval(x, y, 10, 10, 12)
        delay(5)
        cls
    end for
end for


Im doing the same code 4 times, but it changes the position of the ball, so even when it repeats the same code it will put the ball in a different spot

Author:  BangBangMario [ Sun Jan 05, 2014 12:39 pm ]
Post subject:  Re: Grade 10 Student Needs Help!!!

I dont think she taught us that... on the assignment sheet she wrote that we have to use loops though

Author:  Raknarg [ Sun Jan 05, 2014 7:09 pm ]
Post subject:  RE:Grade 10 Student Needs Help!!!

Realistically it shouldnt matter how you solve it. In fact if you solve a problem in a way she was not expecting, that should be bonus marks for you. It shows creative thinking or initiative.

This is using loops though.

Author:  Tony [ Sun Jan 05, 2014 7:37 pm ]
Post subject:  Re: RE:Grade 10 Student Needs Help!!!

Raknarg @ Sun Jan 05, 2014 7:09 pm wrote:
Realistically it shouldnt matter how you solve it. In fact if you solve a problem in a way she was not expecting, that should be bonus marks for you. It shows creative thinking or initiative.

Ideally, yes. It depends on the teacher and the assignment though. Sometimes the assignment is to practice a specific approach. Other times the teacher just has a checklist to mark with.

Raknarg @ Sun Jan 05, 2014 7:09 pm wrote:

This is using loops though.

Depending on the answers above, some might distinguish between loop and for-loop (yes, for-loop is just a special case of the generic loop). Sometimes students just have to recognize what the teacher's particular style of marking is.

Author:  BangBangMario [ Sun Jan 05, 2014 8:36 pm ]
Post subject:  Re: Grade 10 Student Needs Help!!!

Tony is right, my teacher actually does use a checklists and give 1 to 5 marks for each thing i have... she just wants to see if i do it correctly and doest really care what it looks like... and also we only discussed basic loops nothing more complex soo i just want to see if it possible to do it with basic loops

Author:  Raknarg [ Sun Jan 05, 2014 9:13 pm ]
Post subject:  RE:Grade 10 Student Needs Help!!!

Good point. I was spoiled with a good teacher

Author:  BangBangMario [ Tue Jan 14, 2014 8:41 pm ]
Post subject:  Re: Grade 10 Student Needs Help!!!

GUys my assignment is due friday, im freaking out.... i need to learn how to make a clickable menu


alsoo the menu option have to lead us to one of 3 animations (the users choice)... out of those animations im having trouble with one
we need to have cars racing across the screen but each time they have to move at a different speed.... im sooo stuck here
i have the other 2 animations done and the teachers find them the best out of all so far but please help mee

Author:  Raknarg [ Tue Jan 14, 2014 9:40 pm ]
Post subject:  RE:Grade 10 Student Needs Help!!!

You can either look up the Turing GUI module which has buttons, or I can teach you how to use the buttons that I made.

Are you familiar with the GUI module?

Or does someone know a tutorial on here for it?

Author:  Nathan4102 [ Tue Jan 14, 2014 10:03 pm ]
Post subject:  RE:Grade 10 Student Needs Help!!!

Theres lots of tutorials here for GUI stuff: http://compsci.ca/v3/viewtopic.php?t=8808

Author:  BangBangMario [ Wed Jan 15, 2014 4:05 pm ]
Post subject:  Re: Grade 10 Student Needs Help!!!

I prefer Raknarg's teaching... its soo easy to understand

Author:  Raknarg [ Wed Jan 15, 2014 6:26 pm ]
Post subject:  RE:Grade 10 Student Needs Help!!!

Lot's of practice, my friend. Thanks.

Author:  BangBangMario [ Wed Jan 15, 2014 8:17 pm ]
Post subject:  Re: Grade 10 Student Needs Help!!!

no problem lol... but could you please teach me those 2 or 3 concerns i have mentioned... the cars moving at different speed each time i run it and the clickable menu options

Author:  BangBangMario [ Thu Jan 16, 2014 3:52 pm ]
Post subject:  Re: Grade 10 Student Needs Help!!!

I have solved the clickable menu problem... but the cars moving at different speed each time i run them O_O thats a challenge

Author:  BangBangMario [ Thu Jan 16, 2014 7:02 pm ]
Post subject:  Re: Grade 10 Student Needs Help!!!

could you please help me?

Author:  Dreadnought [ Thu Jan 16, 2014 8:57 pm ]
Post subject:  Re: Grade 10 Student Needs Help!!!

You can use Rand.Int to get random values for the speeds.


: