
-----------------------------------
Tsa
Sun May 29, 2011 12:17 pm

Issues with whatdotcolor in platformer
-----------------------------------
What is it you are trying to achieve?
Create a simple platform game.


What is the problem you are having?
I am trying to use whatdotcolor in order to make sure the shape can only jump when it is in the air.


Describe what you have tried to solve this problem
Read a few tutorials on whatdotcolor as well as trying to change the whatdotcolor locations.  I have also used put velocityY so that I am almost certain the issue is around whatdotcolor.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)



var playerX, playerY, velocityX, velocityY : int
var move : array char of boolean
setscreen ("graphics:1200;600, offscreenonly")

% Set variables and constants
playerX := 100
playerY := 50

const XSpeed := 4
const YSpeed := 20
const gravity := 2



% Draw player original position
drawfillbox (playerX - 10, playerY, playerX + 10, playerY + 30, brightgreen)

loop
    velocityX := 0
    velocityY := 0
    % Draw platforms
    drawfillbox (0, 0, maxx, 5, black)
    drawline (0, 150, 150, 150, black)
    drawfillbox (playerX - 10, playerY, playerX + 10, playerY + 20, brightgreen)
    View.Update
    cls
    % Movement
    Input.KeyDown (move)
    if move (KEY_LEFT_ARROW) then
        velocityX := -XSpeed
    end if
    if move (KEY_RIGHT_ARROW) then
        velocityX := XSpeed
    end if
    % Collision detection
    if whatdotcolor (playerX, playerY) not= 0 or whatdotcolor (playerX, playerY - 5) not= 0 then
        if move (KEY_UP_ARROW) then
            velocityY := YSpeed
        end if
    else
        velocityY := -gravity
    end if
    if playerY 