Computer Science Canada [Tutorial] Making a 'Character' move |
Author: | DaveAngus [ Tue Apr 08, 2008 9:31 am ] | ||||||||||||||||
Post subject: | [Tutorial] Making a 'Character' move | ||||||||||||||||
HOW TO MAKE A 'CHARACTER' MOVE WITHIN A GAME At the bottom of this tutorial I have posted a code of the final project. We are going to work together to come out this that program as the final output. The reasonw hy it is there is because if you are truely suck and need to reference it it is there for you help. BUT DONT CHEAT! This will only hurt yourself! Also, this is my first Tutorial. Please offer constructive critisisum It will only help me for future tutorials! OK so first we need to set our variable. I will give you all of the variables that we will use for the wole tutorial. I am taking it that all of you know how to set a variable so that is why I am not focusing on that.
Now we have to initialize all of the variables. Think, what are the boarders of the screen? What is the radius of the circle? And what is the speed of the circle while its moving? You dont want it to move too fast but you dont want it to drag on. NOW TRY TO DO THAT CODE WITHOUT LOOKING DOWN!!!! Also there is a 'black hole' in this code. It is randomly positioned and you have to run into it and it will change location. THat is what the rand int's are below. Please just add them to your code so that we have identical codes.
Ok so now that we have initialized our variables, we need to start the main program We need a loop. To keep it clean why not add a 'cls'? We also need to add the oval and box (black hole) to the code. Now draw a box and an oval. The oval will be our 'character' and out box will be our 'black hole'
Ok so now that we have our 'character', we need to set our key controles. What direction is each arrow going to make the character go? Ok so when we kit the up key we need the program to move the character up. We need it to check the y position and relate it to the radius.
Using this will make you able to move the ball up until it hits the top of the screen. Now this is your turn, Try this with the down,left and right key. Try it without scrolling down. Need help?????
Ok now that the 'character' can be moved, we need to make it so that when you hit the 'black hole' it will recognise that you have hit it and then change location. We are going to need an equasion that checks if the ball has made contact with the 'black hole' You need to check if the xpos is > boxx and if the xpos is < boxx + 25. That will make it check the x position to see if contact has been made. Now we need to check the y position to see if the y axis has been contacted. so why not use an almost identical code to what you used for the xpox and boxx? would ypos > boxy and pos < boxy + 25 work? Ok so now that we have that done, we need to make the box change location when the box is hit. We are going to have to randomize the box x and y position. we we are also going to have to move the box slightly off the the border so that no clipping will occur. You will need 4 randints TRY THIS NOW!!!!!
Now that this has need completed we need to put whats on our buffer to the screen. We also need to end out loop that we started at the beginning of our code.
CONGRATULATIONS you have now completed the task of making a 'character' move!!!! If you have any input on how to better my tutorial just let me know because I would always like to better my work!!! Thank you for taking the time to read this! DAVE ANGUS
|
Author: | BigBear [ Tue Apr 08, 2008 10:46 am ] | ||||||
Post subject: | Re: [Tutorial] Making a 'Character' move | ||||||
Good tutorial I enjoyed the effort put into the structure. This is the constructive criticisms part: In the beginning you could have used constants or added what the value of the variables are when you declared them but the same effect is achieved just a little longer. I do not know if you wanted to create a little bouncing effect to stop the circle from leaving the screen but a simpler and shorter way would be to use one if statement to move
Also you never set the screen to offscreenonly, so someone following you tutorial will have to copy your final program because there output will be all white. And this
can be shortend to
Without the m which I have no idea what it does. |
Author: | DaveAngus [ Tue Apr 08, 2008 11:46 am ] |
Post subject: | RE:[Tutorial] Making a \'Character\' move |
THanks a lot big bear for the post!!! what you are saying is definitly much better. Im just trying to keep it very simple. I could edit that in when Im not in a rush! haha Thanks a lot!!! -Dave |
Author: | Mackie [ Tue Apr 08, 2008 7:26 pm ] |
Post subject: | RE:[Tutorial] Making a \'Character\' move |
I think someone has the Submission forum, confused with the Tutorial forum. |
Author: | riveryu [ Tue Apr 08, 2008 9:15 pm ] |
Post subject: | RE:[Tutorial] Making a \'Character\' move |
I noticed that if you replace the "elsifs" with "ifs and end ifs" then you can move diagonally. Since with elsif the program stop checking for an arrow button being pressed down after one button has been pressed. With if and end if for all of them, the programs checks all buttons every loop. |
Author: | BigBear [ Tue Apr 08, 2008 9:27 pm ] |
Post subject: | Re: [Tutorial] Making a 'Character' move |
Also collision detection or black hole or black box should be any part o the circle hitting any part of the square. |
Author: | A.J [ Tue Apr 08, 2008 9:42 pm ] | ||
Post subject: | Re: [Tutorial] Making a 'Character' move | ||
try going a step further and adding cool graphics by allowing the user to increase/decrease the size of the moving character. here's an example: (NOTE: 'd' for erasing, arrow keys for moving, 'w'/'q' for increasing /decreasing the size of the circle respectively 'a' for filling in the circle with color and lastly, space bar for clearing the screen. have fun!!)
Overall, good structure in the mode of explaining the tutorial, but next time try posting it on the tutorials page |
Author: | BigBear [ Tue Apr 08, 2008 10:13 pm ] | ||
Post subject: | Re: [Tutorial] Making a 'Character' move | ||
Well another to make tutorials interesting are games. Look how much I learned from this tutorial.
Sorry if I modified your code too much. Enjoy. |
Author: | A.J [ Tue Apr 08, 2008 10:28 pm ] |
Post subject: | Re: [Tutorial] Making a 'Character' move |
er........................BigBear, shouldn't you increase the delay ? and try making the game better by adding a character and some effects.........something like this perhaps? |
Author: | Sean [ Wed Apr 09, 2008 6:19 am ] |
Post subject: | Re: [Tutorial] Making a 'Character' move |
There is already a thread that deals with Character Movement. It was created by Tony and I found the way he presented it was more effective then the way you did. This is Tony's Work And, I don't feel the need for critizing other people, and telling htem they suck. Quote: At the bottom of this tutorial I have posted a code of the final project. We are going to work together to come out this that program as the final output. The reason why it is there is because if you are truely suck and need to reference it it is there for you help. BUT DONT CHEAT! This will only hurt yourself! |
Author: | DaveAngus [ Wed Apr 09, 2008 7:02 am ] |
Post subject: | Re: [Tutorial] Making a 'Character' move |
Sean @ Wed Apr 09, 2008 6:19 am wrote: There is already a thread that deals with Character Movement. It was created by Tony and I found the way he presented it was more effective then the way you did.
This is Tony's Work And, I don't feel the need for critizing other people, and telling htem they suck. Quote: At the bottom of this tutorial I have posted a code of the final project. We are going to work together to come out this that program as the final output. The reason why it is there is because if you are truely suck and need to reference it it is there for you help. BUT DONT CHEAT! This will only hurt yourself! Oh geeze man that was a typo. Man I feel like a n00b! haha I meant to type 'STUCK' put 'STUCK' instead of 'SUCK' and the sentence will make much more sence!!!!! |
Author: | Sean [ Wed Apr 09, 2008 6:56 pm ] |
Post subject: | Re: [Tutorial] Making a 'Character' move |
Ah okay, sorry for thinking you were critizing. Before you post, read it over again |
Author: | DaveAngus [ Wed Apr 09, 2008 8:17 pm ] |
Post subject: | RE:[Tutorial] Making a \'Character\' move |
haha yea definitely. Im a terrible spell checker/editor. haha. Big weakness of mine! |