game that wont jump??
Author |
Message |
pokerface
|
Posted: Fri Jun 03, 2005 6:58 pm Post subject: game that wont jump?? |
|
|
i have no idea what so ever on how to make my red dot jump this is the code:
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)
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
|
|
|
![](images/spacer.gif) |
pokerface
|
Posted: Fri Jun 03, 2005 9:19 pm Post subject: (No subject) |
|
|
this may sound funny but how do i make a different platform for my character to jump on!!!
i made the line
code: |
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?
|
|
|
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
Posted: Sat Jun 04, 2005 6:50 am Post subject: (No subject) |
|
|
pokerface wrote: this may sound funny
Not at all.
pokerface wrote:
but how do i make a different platform for my character to jump on!!!
i made the line
code: |
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 Walkthrough. About a third of the way through there is a link to collision detection and another just after it to whatdotcolour.
|
|
|
|
|
![](images/spacer.gif) |
pokerface
|
Posted: Sun Jun 05, 2005 12:14 pm Post subject: (No subject) |
|
|
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!!!!!!!!!!!
|
|
|
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
Posted: Sun Jun 05, 2005 1:11 pm Post subject: (No subject) |
|
|
Here's some simple jumping with whatdotcolour detection:
Turing: |
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.
|
|
|
|
|
![](images/spacer.gif) |
pokerface
|
Posted: Mon Jun 06, 2005 8:05 pm Post subject: (No subject) |
|
|
i could give my character a radius that would do the same thing as what ur saying with the for loop?
|
|
|
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
Posted: Mon Jun 06, 2005 8:27 pm Post subject: (No subject) |
|
|
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.
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
pokerface
|
Posted: Tue Jun 07, 2005 3:21 pm Post subject: (No subject) |
|
|
hey i just wanted to let u guys see what i got so far. please tell me what u think!
Description: |
|
![](http://compsci.ca/v3/pafiledb/images/icons/clip.gif) Download |
Filename: |
Game.rar |
Filesize: |
496.72 KB |
Downloaded: |
94 Time(s) |
|
|
|
|
|
![](images/spacer.gif) |
|
|