trying to make tail grow in snake

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

Username: Password:
RegisterRegister
trying to make tail grow in snake
Index -> Programming, Turing -> Turing Help
Author Message
biggy




Post Posted: Wed Nov 04, 2020 5:32 pm Post subject: trying to make tail grow in snake

What is it you are trying to achieve?
I am trying to make snake


What is the problem you are having?
i keep getting the variable has no value error


Describe what you have tried to solve this problem
well, i like tried for like 4 hours changing it, but i still couldnt get it to work


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
the only way i could get it to work is by using an if statement like if chars ('g') then
x (i) := x (i - 1)
y (i) := y (i - 1)
end if or using an if statement with mouse buttons

Turing:


var xx, yy, xd, yd, size, xxx, yyy, dir, mx, my, mb : int
var g : boolean := true
var chars : array char of boolean


xd := 0
yd := 0

xx := 20
yy := 20

size := 4
dir := 2

var x, y : array 1 .. size of int


x (1) := 10
y (1) := 10








View.Set ("offscreenonly;graphics:600;400")
loop

Input.KeyDown (chars)
Mouse.Where (mx, my, mb)


for decreasing i : size .. 2

x (i) := x (1)
y (i) := y (1)

% area that doesn't work---------------------------------

x (i) := x (i - 1)
y (i) := y (i - 1)


put size

put i
View.Update
Text.Locate (1, 1)
drawfillbox (x (i), y (i), x (i) + 20, y (i) + 20, green )



end for
%keys for control
if chars ('w') then
dir := 1

elsif chars ('a') then
dir := 4


elsif chars ('s') then

dir := 3

elsif chars ('d') then

dir := 2


end if

if dir = 1 then
y (1) := y (1) + 20
elsif dir = 2 then
x (1) := x (1) + 20
elsif dir = 3 then
y (1) := y (1) - 20
elsif dir = 4 then
x (1) := x (1) - 20
end if

drawfillbox (x (1), y (1), x (1) + 20, y (1) + 20, black )
View.Update
cls
delay (100)
end loop




Please specify what version of Turing you are using
4.1.1
Sponsor
Sponsor
Sponsor
sponsor (追記) (追記ここまで) nine90nine




Post Posted: Thu Nov 05, 2020 2:04 pm Post subject: RE:trying to make tail grow in snake

B4 you reply to this post, he did find out how to fix this issue, he just doesn't know how to edit tho, if you don't believe me feel free to reply.
(we are in same class)
biggy




Post Posted: Thu Nov 05, 2020 2:34 pm Post subject: RE:trying to make tail grow in snake

i went into flow state and found out how to fix and fixed in 5 seconds
Display posts from previous:
Index -> Programming, Turing -> Turing Help
Page 1 of 1 [ 3 Posts ]
Jump to:


Style:
Search:


You can syndicate this boards posts using the file backend.php or view the topic map using sitemap.php.


AltStyle によって変換されたページ (->オリジナル) /