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

Username:   Password: 
 RegisterRegister   
 Mapping platforms to an array
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Azaroth




PostPosted: 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)


Turing:


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")
loop
    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
    Draw.ThickLine(xval(i),yval(i),xval2(i),yval2(i),6,black)
    end if
View.Update
end for
delay (1)
end loop



Please specify what version of Turing you are using
4.1.1
Sponsor
Sponsor
Sponsor
sponsor
scholarlytutor




PostPosted: 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?
Azaroth




PostPosted: 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.
wordle




PostPosted: Thu Dec 21, 2023 4:34 am   Post subject: RE:Mapping platforms to an array

check my game https://wordle.cool/game/wordle-uk
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  [ 4 Posts ]
Jump to:   


Style:  
Search: