
-----------------------------------
pokerface
Fri Jun 03, 2005 6:58 pm

game that wont jump??
-----------------------------------
i have no idea what so ever on how to make my red dot jump this is the code:

setscreen ("graphics:600,500")
var x, y : int
x := 13
y := 13
var chars : array char of boolean
View.Set ("offscreenonly")
loop
    Input.KeyDown (chars)
    % if chars (KEY_UP_ARROW) and y < 487 then
    %     y := y + 1
    % end if
    % if chars (KEY_DOWN_ARROW) and y > 13 then
    %     y := y - 1
    % end if
    if chars (KEY_LEFT_ARROW) and x > 13 then
        x -= 1
    end if
    if chars (KEY_RIGHT_ARROW) and x < 587 then
        x += 1
    end if
    if chars (' ') then

    end if
    if chars ('r') then
        cls
    end if
    drawbox (1, 1, 599, 499, black)
    drawfilloval (x, y, 10, 10, brightred)
    drawdot (x, y, white)
    %drawoval (x, y, 10, 10, brightred)
    delay (5)
    View.Update
end loop

im new to part of turing (part= to gui movement)

-----------------------------------
Cervantes
Fri Jun 03, 2005 7:16 pm


-----------------------------------
Here's links to two threads that you should read, regarding jumping.  I think they will answer your questions.

http://www.compsci.ca/v2/viewtopic.php?t=7019
http://www.compsci.ca/v2/viewtopic.php?t=6431

There's a rather long post be me in this first link (several posts down, you can't miss it :wink:) that should be all you need.  But there's more material if you wish. :)

-----------------------------------
pokerface
Fri Jun 03, 2005 9:19 pm


-----------------------------------
this may sound funny but how do i make a different platform for my character to jump on!!!

i made the line
  
 drawfillbox (60, 36, maxx, 40, black)

and now i want my character to stop on top of it when i jump on it? other words how do i make this platform a soild?

-----------------------------------
Cervantes
Sat Jun 04, 2005 6:50 am


-----------------------------------
this may sound funny
Not at all. :)

but how do i make a different platform for my character to jump on!!!

i made the line
  
 drawfillbox (60, 36, maxx, 40, black)

and now i want my character to stop on top of it when i jump on it? other words how do i make this platform a soild?
You're asking about collision detection.  There are several different ways to do this.  One is using an if statement to check if the y value of your character is between certain values and the x value as well.  Another method is to use whatdotcolour.
Check out the [url=http://www.compsci.ca/v2/viewtopic.php?t=8808]Walkthrough.  About a third of the way through there is a link to [url=http://www.compsci.ca/v2/viewtopic.php?t=75]collision detection and another just after it to [url=http://www.compsci.ca/v2/viewtopic.php?t=2381]whatdotcolour.

-----------------------------------
pokerface
Sun Jun 05, 2005 12:14 pm


-----------------------------------
no how many times i read the tuts i cant understand what to do with my line!!! please someone tell me exacly how to make it so i could learn from it and make more lines with the same formula!!! i really been reading and reading but i cant put it all together
!!!!!!!!! PLEASE HELP!!!!!!!!!!!

-----------------------------------
Cervantes
Sun Jun 05, 2005 1:11 pm


-----------------------------------
Here's some simple jumping with whatdotcolour detection:

View.Set ("offscreenonly")
const gravity := 0.15
var x, y, vy : real
x := maxx / 2
y := 20
vy := 0
var jumping := false

var keys : array char of boolean
loop

    if whatdotcolour (round (x), round (y - 11)) = black then %radius is 10. go one below it.
        jumping := false
        vy := 0
    end if
    if whatdotcolour (round (x), round (y + 11)) = black then   %check one above it
        vy := 0
    end if

    Input.KeyDown (keys)
    if keys (KEY_UP_ARROW) and not jumping then
        jumping := true
        vy := 5
    end if
    if keys (KEY_LEFT_ARROW) then
        x -= 2
    end if
    if keys (KEY_RIGHT_ARROW) then
        x += 2
    end if
    if jumping then
        vy -= gravity
    end if
    y += vy

    cls
    drawfilloval (round (x), round (y), 10, 10, black)  %draw character
    drawfillbox (0, 60, 200, 70, black)                 %draw platform
    drawfillbox (0, 0, maxx, 10, black)                 %draw floor
    View.Update
    delay (10)

end loop

Notice, however, that you can do some funky things, like if you jump off the platform and then start to move back towards it while in mid jump, you can sort of hang on the bottom of the platform, if timed correctly.  To fix this, you'd need to check more than just directly under the player.  You'd have to use a for loop and check all across his width.

-----------------------------------
pokerface
Mon Jun 06, 2005 8:05 pm


-----------------------------------
i could give my character a radius that would do the same thing as what ur saying with the for loop?

-----------------------------------
Cervantes
Mon Jun 06, 2005 8:27 pm


-----------------------------------
Just giving it a radius doesn't help.  What I think you are saying is check at his left and right edges, as well.  Well, kinda.  What I'm suggesting, however, is you check every single pixel in a horizontal line underneath the character.  

Now, provided you don't have any platforms that are one pixel wide, you could only check every other pixel.  If you're smallest platform is 5 pixels, wide, you could check every 5 pixels.  You should, however, at least check on either side of the character.

-----------------------------------
pokerface
Tue Jun 07, 2005 3:21 pm


-----------------------------------
hey i just wanted to let u guys see what i got so far. please tell me what u think!
