Computer Science Canada

Mapping platforms to an array

Author:  Azaroth [ Thu Apr 06, 2023 11:06 am ]
Post subject:  Mapping platforms to an array

What is it you are trying to achieve?
I'm a bit new to turing, but I'm trying to make a platforming game where you make your own platforms to complete the level. I'm attempting to have each new line be a different value in an array.

What is the problem you are having?
I cannot figure out how to give each line a new value.

Describe what you have tried to solve this problem
Again I'm pretty new to this, so I've only ben able to try for statements and other than that I'm pretty clueless

Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)


var x, y, button : int
var count, upperlimit : int
var check := false
upperlimit := 10
var xval, yval, xval2, yval2 : array 1 .. upperlimit of int
count := 0
View.Set ("offscreenonly")
    Mouse.Where (x, y, button)
    for i : 1 .. 10
    %%%%%%%%%%%%%%%%%%%%%%%%%%%% Get first point from mouse click %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    if button = 1 and count <= 0 then
            xval (i) := x
            yval (i) := y
            count += 1
    end if
    %%%%%%%%%%%%%%%%%%%%%%%%%%%% Get second point from mouse release %%%%%%%%%%%%%%%%%%%%%%%%%%%
    if button = 0 and count > 0 then
    xval2(i) := x
    yval2(i) := y
    count := 0
    end if
end for
delay (1)
end loop

Please specify what version of Turing you are using

Author:  scholarlytutor [ Thu Apr 06, 2023 4:30 pm ]
Post subject:  RE:Mapping platforms to an array

It seems to be working for me. I click and drag, and each time I get a new line to show.

Just to clarify, are you trying to save the X/Y values of each platform the user creates to use those values later in the game?

Author:  Azaroth [ Fri Apr 07, 2023 7:15 am ]
Post subject:  RE:Mapping platforms to an array

I realize now it’s a bit difficult to see with my current code, but I don’t cls at any point, which means each new line is updating the first sets of x,y coordinates, which would make collision for each of the previous lines impossible. The idea I’m going for is each new line you draw becomes a new platform with its own separate values/variables that can later be used for detections and collisions.