
-----------------------------------
william 01
Wed Jun 02, 2010 5:01 pm

Movement HELP!
-----------------------------------
What is it you are trying to achieve?



What is the problem you are having?



Describe what you have tried to solve this problem



Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)








Please specify what version of Turing you are using
4.0?

-----------------------------------
Insectoid
Wed Jun 02, 2010 5:20 pm

RE:Movement HELP!
-----------------------------------
Your problem is in your variables. You need some. No integers though, they mess things up something awful. Use only strings. It helps if you put /* at the top of the program and */ at the bottom, I guarantee you will not get a single error. 

The real key to effective moving is trigonometry. Using some complicated functions written to inefficiently perform algebra on strings ('cause integers are bad, remember?) you can calculate the projected path of the object to move based on input received from the keyboard (which in itself requires calculation of second derivatives of the input function to detect which keys are NOT pressed. 

It's hopeless. You should probably give up now.

-----------------------------------
DemonWasp
Wed Jun 02, 2010 6:30 pm

RE:Movement HELP!
-----------------------------------
What Insectoid means is that you haven't given us any details on what to help you with. We won't write code for you. You need to try to solve the problem yourself (hint: pencil and paper first!) and then arrive at a problem, analyze the problem, try to solve it, etc.

If you run into a specific problem that you can't seem to solve, then ask for help.

If you want to look at tutorials, try the Turing Tutorials section.

-----------------------------------
william 01
Wed Jun 02, 2010 6:56 pm

Re: Movement HELP!
-----------------------------------
What is the problem you are having? 
to get mario moving and jumping  

Describe what you have tried to solve this problem 
tried using the movement tutorial 

Post any relevant code (You may choose to attach the file instead of posting the code if it is too long) 
Turing:


%The Egyptian Adveture Game 
%by William Frisk 
%May 17, 2010 

setscreen ("graphics:934;394,nobuttonbar,nocursor") 
%Variables 
var pic1 : int := Pic.FileNew ("background.bmp") 
var font1 := Font.New ("Papyrus:35") 
var font2 := Font.New ("Papyrus:45") 
var font3 := Font.New ("Times New Roman:18") 
var a1 : string 


%intro 
Pic.Draw (pic1, 0, 0, 0) 
Draw.Text ("Welcome to the...", 40, 210, font1, black) 
delay (1000) 
Draw.Text ("Egyptian Adventure Game!", 120, 100, font2, black) 
delay (2000) 
cls 

%Instruction 
Pic.Draw (pic1, 0, 0, 0) 
Draw.Text ("By using the arrow keys to move the player left (for left), right (for right) and", 25, 210, font3, black) 
Draw.Text ("jump (with the up arrow) try to getto the exit point while avoiding the spikes.", 25, 170, font3, black) 
Draw.Text ("The spikes will cause your health to decrease until you get off the", 25, 130, font3, black) 
Draw.Text ("spikes or until you die.", 25, 90, font3, black) 
Draw.Text ("Understand?", 23, 40, font3, black) 
locate (22, 20) 
delay (3000) 
cls 

%Level/player Variables 
var lone : array 1 .. 2 of int 
lone (1) := Pic.FileNew ("level 11.bmp") 
lone (2) := Pic.FileNew ("level 12.bmp") 
var mario : int := Pic.FileNew ("mario.bmp") 
var chars : array char of boolean 
var x1 : int := 27 
var y1 : int := 28 
var vx : int := 0 
var vy : int := 0 
var js : int := 60 

%Level One 
proc movement 
    if chars (KEY_LEFT_ARROW) and whatdotcolour (x1 - 10, y1 + 24) not= black then 
        vx := -10 
    elsif chars (KEY_RIGHT_ARROW) and whatdotcolour (x1 + 10, y1 + 24) not= black then 
        vx := 10 
    else 
        vx := 0 
    end if 
    if chars (KEY_UP_ARROW) and y1 < maxy - 25 and whwhatdotcolorx1, y1 - 10) = black then 
        vy := js 
    end if 
end movement 
cls 
Input.KKeyDown(chars) 
Pic.Draw (lone (2), 0, 0, ppicCopy 
movement 
Pic.Draw (lone (1), 0, 0, picCopy) 
Pic.Draw (mario, x1, y1, picMerge) 
View.Update 

sorry when i posted it some how erased when i sent it.

-----------------------------------
william 01
Wed Jun 02, 2010 7:05 pm

Re: Movement HELP!
-----------------------------------
i tryed to post atachments but they wont let me post more than one.

-----------------------------------
Insectoid
Wed Jun 02, 2010 7:42 pm

RE:Movement HELP!
-----------------------------------
This line has a syntax error in it:
[code]
if chars (KEY_UP_ARROW) and y1 < maxy - 25 and whwhatdotcolorx1, y1 - 10) = black then [/code]

Anyway, you're doing it right so far. You're just missing the important bit where we actually update the position (x1, y1). Just before you draw everything (or just after, your choice) but inside the main loop, you need to add

[code]
x1 += vx
y1 += vy
[/code]

You'll also need to add gravity to do jumping, so in the loop you need to check if the character (mario I assume in this case) is standing on something, and if not, subtract N from vy (N being whatever you set your gravity to). 

Also, you need to call your 'movement' procedure somewhere in the main loop you need to have.

-----------------------------------
william 01
Thu Jun 03, 2010 4:00 pm

Re: Movement HELP!
-----------------------------------
in my case how would i put in gravity

-----------------------------------
TheGuardian001
Thu Jun 03, 2010 4:07 pm

Re: Movement HELP!
-----------------------------------
Keep on moving the character (And everything else that gravity will effect) down. So just have a certain amount subtracted from the character's y coordinate (or from y velocity, as long as you do it before subtracting y velocity from y coordinate) every time the main loop runs.

-----------------------------------
william 01
Thu Jun 03, 2010 4:13 pm

Re: Movement HELP!
-----------------------------------
Keep on moving the character (And everything else that gravity will effect) down. So just have a certain amount subtracted from the character's y coordinate (or from y velocity, as long as you do it before subtracting y velocity from y coordinate) every time the main loop runs.

explan please :?

-----------------------------------
USEC_OFFICER
Thu Jun 03, 2010 4:21 pm

RE:Movement HELP!
-----------------------------------
It's very easy.

Y is the y-coordinate of the character. i.e. Up-down.

By subtacting a set number from Y, the character will move down, simulating gravity.

If you have a varible that replaces the set number, you can change the strength of the gravity.

-----------------------------------
william 01
Thu Jun 03, 2010 4:22 pm

Re: RE:Movement HELP!
-----------------------------------

 update the position (x1, y1). Just before you draw everything (or just after, your choice) 

insectoid could you post example?

ps every one thank you for your help but "mario" still won't move.

-----------------------------------
Insectoid
Thu Jun 03, 2010 5:07 pm

Re: RE:Movement HELP!
-----------------------------------

 update the position (x1, y1). Just before you draw everything (or just after, your choice) 

insectoid could you post example?

ps every one thank you for your help but "mario" still won't move.

[code]
x1+=vx
vy -= gravity
y1+=vy
[/code]

Done.
