Posted: Tue Sep 10, 2013 4:54 pm Post subject: Just a question, and some guidance needed please!
Hey there, yes im a complete noob at programming, ik lol, i was first wondering if it was possible to add delay to a
put "" statement.. like, lets say..
put "Hello."
Is there a way to have the program basically type that out? Like, have delay before each letter? if so, how would one do that?
Also!
My platformer game is still having some issues, nooby issues, but still..
I want it so that if you jump under a line, you bounce down.. i have it so you can jump ON the line, but right now, if you jump under the line, you super jump, and its kinda funny tbh.. Just some guidance would be nice. thanks!
Platformer code
code:
const Gravity := 2
var x, y := 100
var y_velocity := 0
var keys : array char of boolean
var tiles : array 0..35, 0..35 of int
setscreen ("offscreenonly,graphics:500;500")
var Height := 150
var Length := 150
loop
Input.KeyDown (keys)
if keys (KEY_UP_ARROW) and y <= 0 then
y_velocity := 30
end if
if keys (KEY_LEFT_ARROW) and x > 0 then
x -= 10
end if
if keys (KEY_RIGHT_ARROW) and x < maxx then
x+= 10
end if
y_velocity -= Gravity
y += y_velocity
if y < 0 then
y := 0
y_velocity := 0
end if
if Math.DistancePointLine (x,y, 50, 100,150,100) < 15 then
y := 100
y_velocity := 0
if keys (KEY_UP_ARROW) and y <= 100 then
y_velocity := 30
end if
end if
Draw.FillOval(x,y,15,15,blue)
drawline(50,100,150,100,blue)
View.Update
delay (5)
cls
end loop
the first question doesn't have code, i just wanna know if its poss and how one would get it to work. thanks again
Sponsor Sponsor
Nathan4102
Posted: Tue Sep 10, 2013 5:20 pm Post subject: RE:Just a question, and some guidance needed please!
Definitely possible, you're going to want to use locate(x, y), put(), and delay(). Look into those 3 functions/procedures in the documentation, and if you still need a hand, I can write it out for you. I'll take a look at your code now, no promises I'll find your problem though! :p
Raknarg
Posted: Tue Sep 10, 2013 5:21 pm Post subject: RE:Just a question, and some guidance needed please!
As for your first problem, you can hard code it. There's a little thing you can throw in so that instead of making a new line, the next put or get statement appends on the old one. Look at this:
As for your platformer problem, the issue is in this line:
Turing:
if keys (KEY_UP_ARROW)and y <= 100then
y_velocity :=30 endif
Basically according to your code, if you're within range of the platform, then you automatically land on it. So, what you need to include is a method that determines whether or not you're coming from the bottom of the line or the top.
slender0123
Posted: Tue Sep 10, 2013 5:25 pm Post subject: RE:Just a question, and some guidance needed please!
Could you possibly explain deeper into the platform problem? And thanks for the delay thing
Raknarg
Posted: Tue Sep 10, 2013 5:35 pm Post subject: RE:Just a question, and some guidance needed please!
Well, you're going to have two different actions. If you touch it from above, you want to land on it. If it's from under, then you want to bounce off. Therefore, the thing you have to determine is the direction you're coming from.
Nathan4102
Posted: Tue Sep 10, 2013 5:36 pm Post subject: RE:Just a question, and some guidance needed please!
Well if you're coming from underneath the line, you want your character to hit his head, right? The way you've coded it now, you're just sticking to the line if the character is near it. Look here:
My suggestion is that after checking if you're close to the line, check if you're currently above it or below it. If you're below it, you hit your head and go back down.
slender0123
Posted: Tue Sep 10, 2013 5:44 pm Post subject: RE:Just a question, and some guidance needed please!
As in 2 differenct actions being a boolean action or a elsif (KEY_UP_ARROW)?
I am right now, trying out the elsif part, boolean is next..
slender0123
Posted: Tue Sep 10, 2013 6:07 pm Post subject: RE:Just a question, and some guidance needed please!
Too be brutaly honist, I can't figure it out =[ I feel so nub lol
Sponsor Sponsor
Nathan4102
Posted: Tue Sep 10, 2013 6:42 pm Post subject: RE:Just a question, and some guidance needed please!
Turing:
ifMath.DistancePointLine(x,y, 50, 100,150,100) < 15then
y :=100
y_velocity :=0 if keys (KEY_UP_ARROW)and y <= 100then
y_velocity :=30 endif endif
Ok, this is the culprit right here. This is basically saying "If we're near the line, we've landed above it, so make us stop.", which isn't true at all. Instead, we should add a check to see weather we're actually above the line, or perhaps below the lin. We can do this like this:
Turing:
ifMath.DistancePointLine(x, y, 50, 100, 150, 100) < 15then if y >= 100then%If we're above or on the line, make us stop
y :=100
y_velocity :=0 else%Otherwise, we've just hit our head, so we should start heading down
y :=99
y_velocity := -10 endif if keys (KEY_UP_ARROW)and y <= 100then
y_velocity :=30 endif endif
Does this make sense?
slender0123
Posted: Tue Sep 10, 2013 6:59 pm Post subject: RE:Just a question, and some guidance needed please!
Doesn't work =p But it does kinda make sense.
Raknarg
Posted: Wed Sep 11, 2013 10:44 am Post subject: RE:Just a question, and some guidance needed please!
WE ca do something even simpler. If your lines are always flat, then you just look at your speed. If you are falling down, you want to land on the platform. If you're going up, you want to bounce off.
Nice and simple. It's a little more complex if your lines are tilted, but for now that should be easy enough
slender0123
Posted: Wed Sep 11, 2013 5:10 pm Post subject: RE:Just a question, and some guidance needed please!
I dont plan on making tilted lines in my platformer, could you possibly show me the coding for something like that?
Raknarg
Posted: Wed Sep 11, 2013 5:25 pm Post subject: RE:Just a question, and some guidance needed please!
Ill give you some pseudo code.
Turing:
if collidesWithPlatform ()then if velocity < 0then
landOnPlatform () else
velocity := velocity * -1 endif endif
slender0123
Posted: Wed Sep 11, 2013 6:19 pm Post subject: RE:Just a question, and some guidance needed please!
Ok, thatnks
Is there a certain spot i should put
code:
if keys (KEY_UP_ARROW) () then
blah blah blah
?
because i find if its in the if math.distance statement, i can easily hold up and basically super jump.
Nathan4102
Posted: Wed Sep 11, 2013 6:22 pm Post subject: RE:Just a question, and some guidance needed please!
Well if we tell you exactly where to put everything, you arent really making a game, are you? Try to read your program, understand the flow of the program, understand what everything means in your program. When you understand that, you should know where to put it.
If you've tried your hardest and STILL can't figure it out, then you can come to us. Having us do it ruins the fun!