Help with simple grpahical program
Author |
Message |
Kami
|
Posted: Wed Sep 07, 2011 9:06 pm Post subject: Help with simple grpahical program |
|
|
What is it you are trying to achieve?
I am trying to create a simple program that would move around a small circle on the screen using the keys WAS and D
What is the problem you are having?
Turing is telling me no errors, and my code looks fine but the program does not work
Describe what you have tried to solve this problem
I looked over my code multiple times, I have tried re-arranging it, and there is not much else.
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Turing: |
import GUI
setscreen("graphics:300;125")
var x := 100
var y := 100
var xchange := 0
var ychange := 0
procedure movement
const RADIUS : int := 5
Draw.Cls
Draw.Oval ( x, y, RADIUS,RADIUS, black)
x + = x + xchange
y + = x + ychange
end movement
procedure xchangeup
xchange := xchange + 5
movement
end xchangeup
procedure xchangedown
xchange := xchange - 5
movement
end xchangedown
procedure ychangeup
ychange := ychange + 5
movement
end ychangeup
procedure ychangedown
ychange := ychange - 5
movement
end ychangedown
var buttonup : int := GUI.CreateButtonFull (50, 100, 0, "Up",xchangeup, 0, '^W', false)
var buttondown: int := GUI.CreateButtonFull (50, 0, 0, "Down",xchangedown, 0, '^S', false)
var buttonleft : int := GUI.CreateButtonFull (0, 50, 0, "Left",ychangedown, 0, '^A', false)
var buttonright: int := GUI.CreateButtonFull (100, 50, 0, "Right",ychangeup, 0, '^D', false)
movement
|
Please specify what version of Turing you are using
I believe it is 4.1.1, the latest one that you can get from CompSci
I am very new to turing syntax, but I do have some experience in other programming languages. It would be nice if you cold explain any syntax that I might need for this.
Not really urgent, but I do need an answer please. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Aange10
![](http://compsci.ca/v3/uploads/user_avatars/19166165534f400d42de502.png)
|
Posted: Wed Sep 07, 2011 9:22 pm Post subject: RE:Help with simple grpahical program |
|
|
Alright, it looks to me like just some syntax problems. I recommend you go to http://compsci.ca/v3/viewtopic.php?t=114 to learn the syntax. It will teach you everything you need to know about inputting key strokes.
Ironoically, the first bit of info in the tutorial is how to make a red ball move in a circle. So you should find the solution to all your errors there (:
ALSO: I recommend you read the EXTREMELY helpful guide here: http://compsci.ca/v3/viewtopic.php?t=8808 |
|
|
|
|
![](images/spacer.gif) |
Raknarg
![](http://compsci.ca/v3/uploads/user_avatars/3745510004d8be6689b92f.jpg)
|
Posted: Sat Sep 10, 2011 10:38 am Post subject: RE:Help with simple grpahical program |
|
|
You're going about this the wrong way. There's no need for GUIs, only a little thing called Input.KeyDown. Use the first link Aange10 gave you and you'll be fine. |
|
|
|
|
![](images/spacer.gif) |
|
|