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

Username:   Password: 
 RegisterRegister   
 Correcting Platform Collisions
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
computers321




PostPosted: Sat Jun 18, 2016 2:09 pm   Post subject: Correcting Platform Collisions

What is it you are trying to achieve?
Trying to code a 2D platformer game as my final task for Computer Science.


What is the problem you are having?
My platform collisions don't entirely work. I can jump up onto platforms and jump on them multiple times (thanks to some tutorials I found here), but when I try and jump down onto another platform, the character (right now a box) falls straight through.


Describe what you have tried to solve this problem
Tried to use whatdotcolour, didn't work very well. Tried to play with the collision if statements, still not working.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Here's the specific area, the file is in its entirety below.

Turing:


if chary <= PLATFORM and chary >= PLATFORM - 4 and charx >= 0 and charx <= 100 and charyv < 0 then
        chary := PLATFORM
        charyv := 0
    elsif chary <= PLATFORM and chary >= PLATFORM - 4 and charx >= 0 and charx <= 100 and charyv > 0 then
        chary := PLATFORM
    end if

    if chary <= PLATFORM + 60 and chary >= PLATFORM + 56 and charx >= 120 and charx <= 210 and charyv < 0 then
        chary := PLATFORM + 60
        charyv := 0
    elsif chary <= PLATFORM + 60 and chary >= PLATFORM + 56 and charx >= 120 and charx <= 210 and charyv > 0 then
        chary := PLATFORM + 60
    end if

    if chary <= PLATFORM + 140 and chary >= PLATFORM + 136 and charx >= 30 and charx <= 90 and charyv < 0 then
        chary := PLATFORM + 140
        charyv := 0
    elsif chary <= PLATFORM + 140 and chary >= PLATFORM + 136 and charx >= 30 and charx <= 90 and charyv > 0 then
        chary := PLATFORM + 140
    end if

    if chary <= PLATFORM + 150 and chary >= PLATFORM + 146 and charx >= 230 and charx <= 300 and charyv < 0 then
        chary := PLATFORM + 150
        charyv := 0
    elsif chary <= PLATFORM + 150 and chary >= PLATFORM + 146 and charx >= 230 and charx <= 300 and charyv > 0 then
        chary := PLATFORM + 150
    end if

    if chary <= PLATFORM + 30 and chary >= PLATFORM + 26 and charx >= 530 and charx <= 600 and charyv < 0 then
        chary := PLATFORM + 30
        charyv := 0
    elsif chary <= PLATFORM + 30 and chary >= PLATFORM + 26 and charx >= 530 and charx <= 600 and charyv > 0 then
        chary := PLATFORM + 30
    end if

    if chary <= PLATFORM + 70 and chary >= PLATFORM + 66 and charx >= 420 and charx <= 510 and charyv < 0 then
        chary := PLATFORM + 70
        charyv := 0
    elsif chary <= PLATFORM + 70 and chary >= PLATFORM + 66 and charx >= 420 and charx <= 510 and charyv > 0 then
        chary := PLATFORM + 70
    end if



These statements deal with platform collisions.

Please specify what version of Turing you are using
It's an IDE to be used on OS X. It's called Turing IDE - Made by Oswald Pan. Seems to have everything 4.1.1 has.



level 1.t
 Description:
Here's my first level.

Download
 Filename:  level 1.t
 Filesize:  8.62 KB
 Downloaded:  265 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
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  [ 1 Posts ]
Jump to:   


Style:  
Search: