Posted: Wed Dec 07, 2011 6:23 pm Post subject: Graphics and jump
What is it you are trying to achieve?
I want to make this like jumping game that you jump from pad to pad, ill make the hp later.
What is the problem you are having?
As you can see down there the code that i tried to put for boundaries for the pads did not work, like i wanted to make it so that you can step on the pads, also i can jump midway in the air, what i want is a set jump and when you reach the floor you can jump again
Describe what you have tried to solve this problem
I have tried looking at other peoples games and code like mine
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>
var count, count2, count1, x, y :int var HP :int:=100%declaring the health points const HL :int:=100%declaring health bar length var damage :int:=1%declaring the damage var mx, my :int%vars for the mouse where code
x :=400
y :=400 var c :int
c :=10 var chars :arraycharofboolean%will make key input without 'get' command
my :=100
mx :=500 loop
if chars (KEY_UP_ARROW)and my < 100then%movements
my := my + 1 elsif chars (KEY_UP_ARROW)and my >= 100then
my := my + 11 elsif chars (KEY_DOWN_ARROW)then
my := my - 1 elsif chars (KEY_RIGHT_ARROW)then
mx := mx + 1 elsif chars (KEY_LEFT_ARROW)then
mx := mx - 1 elsif chars (KEY_ENTER)then
endif %Draws oval
if my > 100then%boundaries
my := my - 4 elsif my < 93then
my :=93 elsif my > 300and mx < 300and my < 250then
my :=300 elsif mx > 890then
mx :=890 elsif mx < 10then
mx :=10 endif
Please specify what version of Turing you are using
newest
Sponsor Sponsor
programmer1337
Posted: Wed Dec 07, 2011 7:11 pm Post subject: Re: Graphics and jump
someone anyone????
Insectoid
Posted: Wed Dec 07, 2011 7:17 pm Post subject: RE:Graphics and jump
Try looking up a jumping tutorial? There are many. I know, because I wrote one of them. The Tutorial section exists for a reason.
Aange10
Posted: Wed Dec 07, 2011 7:29 pm Post subject: RE:Graphics and jump
Think about it. Here's one answer...
Quote:
what i want is a set jump and when you reach the floor you can jump again
Turing:
var setJump :boolean:=false if you =floorthen
setJump :=true endif
if setJump =truethen %jump endif
Dreadnought
Posted: Wed Dec 07, 2011 7:33 pm Post subject: Re: Graphics and jump
If I may just bring this to your attention (I promise its relevant to your code).
Note : IsEven?, IsOdd?, and IsNegative? are just made up names for functions that don't exist (but could exist if someone wrote them, except for the ?)
Turing:
var num :int put"Input a number" get num
if IsOdd? (num)then% Check if odd put"Your number is odd!" elsif IsEven? (num)then% Check if even put"Your number is even!" elsif IsNegative? (num)then% Check if negative put"Your number is negative!" endif
What do you think will happen when I input a negative number?
programmer1337
Posted: Wed Dec 07, 2011 7:48 pm Post subject: Re: Graphics and jump
i got the jump down, now all i need really is to make me not be able to go through the platforms
programmer1337
Posted: Wed Dec 07, 2011 8:00 pm Post subject: Re: Graphics and jump
that is my current code and it will change the ground height to the platform, BUT it will not let you down if you go over the edge, and it wont let you jump to the next one, sooo any ideas of what i should do?
var count, count2, count1, x, y : int
var HP : int := 100 %declaring the health points
const HL : int := 100 %declaring health bar length
var damage : int := 1 %declaring the damage
var mx, my : int %vars for the mouse where code
var GROUND_HEIGHT := 100
const RUN_SPEED := 10
const JUMP_SPEED := 40
const GRAVITY := 2
var velx, vely : real
vely := 0
velx := 0
x := 400
y := 400
var c : int
c := 10
var chars : array char of boolean %will make key input without 'get' command
my := 100
mx := 500
loop
cls ()
Input.KeyDown (chars)
if chars (KEY_RIGHT_ARROW) then
velx := RUN_SPEED
elsif chars (KEY_LEFT_ARROW) then
velx := -RUN_SPEED
else
velx := 0
end if
if chars (KEY_UP_ARROW) and my = GROUND_HEIGHT then
vely := JUMP_SPEED
end if
vely -= GRAVITY
mx += round (velx)
my += round (vely)
if my < GROUND_HEIGHT then
my := GROUND_HEIGHT
vely := 0
end if
%Draws oval
if my < 300 and my > 200 and mx < 300 then
if mx > 300 then
GROUND_HEIGHT := 100
elsif mx < 300 then
GROUND_HEIGHT := 300
end if
end if
if my < 450 and my > 300 and mx > 600 then
GROUND_HEIGHT := 450
end if
if my > 100 then %boundaries
my := my - 6
elsif my < 93 then
my := 93
elsif my > 790 then
my := 790
elsif mx > 990 then
mx := 990
elsif mx < 10 then
mx := 10
end if
Draw.FillBox (0, 0, 1200, 800, 79) %keeps updating the sky, and drawing sky
Draw.FillBox (0, 200, 300, 150, green) % platform
Draw.FillBox (600, 300, 1000, 350, green) % platform
Draw.FillBox (0, 200, 300, 150, green) % platform
Draw.FillBox (1, maxy - 19, HP, maxy - 10, green) %inside healthbox
Draw.Box (1, maxy - 19, HL, maxy - 10, black) %health box outline
Draw.FillOval (mx, my, 10, 10, black)
Draw.Line (mx, my - 50, mx, my, black)
Draw.Line (mx - 25, my - 30, mx, my - 20, black)
Draw.Line (mx + 25, my - 30, mx, my - 20, black)
Draw.Line (mx - 20, my - 90, mx, my - 47, black)
Draw.Line (mx + 20, my - 90, mx, my - 47, black)
Draw.ThickLine (300, 0, 315, 20, 5, black)
c := c + 1
Draw.FillOval (c, 700, 50, 50, yellow)
View.Update
exit when chars (KEY_ESC)
end loop
Dreadnought
Posted: Wed Dec 07, 2011 8:14 pm Post subject: Re: Graphics and jump
As a followup to my last post, which describes part of your problem, here's something else to consider.
Note: Again this code wont run since IsOdd? and IsEven? don't exist.
Turing:
var num :int put"Input a number from 1 to 100" get num
% Make sure number is between 1 and 100 if num > 100then
num :=100 elsif num < 1then
num :=1 endif
if IsEven? (num)then% Check if even put"Your number is even!" elsif IsOdd? (num)then% Check if odd put"Your number is odd!" endif
What happens if I input an odd number bigger than 100 or an even number smaller than 1?
Sponsor Sponsor
programmer1337
Posted: Wed Dec 07, 2011 8:16 pm Post subject: Re: Graphics and jump
first of all you didnt declare the variables so it wouldnt do anything, but if you did it would say the appropriate put statement, and please can you help em with something pertaining to my problem, i mean doesnt have to be my code exactly could be something else but something very similar lol
Dreadnought
Posted: Wed Dec 07, 2011 8:22 pm Post subject: Re: Graphics and jump
programmer1337 wrote:
first of all you didnt declare the variables so it wouldnt do anything, but if you did it would say the appropriate put statement
Firstly, I told you the code wouldn't run. I'm trying to make you think about it rather than ask turing to tell you what happens.
Second, my whole point is that the message might not be appropriate.
Your code has problems that are similar to the ones in the code I posted.
programmer1337
Posted: Wed Dec 07, 2011 8:23 pm Post subject: Re: Graphics and jump
like whatttt idk what it rofl
Dreadnought
Posted: Wed Dec 07, 2011 8:38 pm Post subject: Re: Graphics and jump
Ok, let me make something simpler that will run in turing.
Turing:
var num :int put"Input an odd number bigger than 100" get num
cls if num > 100then
num :=100 endif put"The number you input is: ", num
put"Is this number odd?" put"Now think about my other examples"
programmer1337
Posted: Wed Dec 07, 2011 8:40 pm Post subject: Re: Graphics and jump
well basically you are asking for an odd number bigger than 100, and you are getting that from the user but you are also making an if statement that is setting num to 100 which is not odd or bigger than 100
Dreadnought
Posted: Wed Dec 07, 2011 8:53 pm Post subject: Re: Graphics and jump
Good, now look at this.
Turing:
var x :int:=0
loop cls
x +=1 Draw.Oval(x, 200, 10, 10, 7) if x > 300then
x:=300 endif Time.Delay(10) endloop
Why does the oval stop moving even though I'm changing its x position all the time.
programmer1337
Posted: Wed Dec 07, 2011 9:18 pm Post subject: Re: Graphics and jump
it is bringing it back to 300 because so it doesnt go past it