Collecting items and restarting level, and using txt files for loading in a level in vertical-scrolling platformer
Author |
Message |
TigerFallOut
|
Posted: Fri Dec 16, 2011 10:40 pm Post subject: Collecting items and restarting level, and using txt files for loading in a level in vertical-scrolling platformer |
|
|
What is it you are trying to achieve?
I have a vertical scrolling game where you have to jump on platforms towards the goal (i havent put the goal yet) while collecting some items that add to a point counter.
1. I am trying to collect the items (actually touching it, then adding to the score and hiding it after collecting it) when the screen is scrolling but there seems to be an issue with the boundaries.
2. Something else I'm trying to do is to be able to restart a level after you fall off the screen (gameover). The platforms and items load from another turing file (include "file.t"), so that might be the problem.
3. I want to be able to load a level from a txt file and not a turing file so that it is easier to change a level and to load the level. Could someone explain how to set it up and include it in turing? Preferable with my variable names (or concepts) so I can use that as a template
4. Clean up code, more efficient etc..
What is the problem you are having?
1. When the game isnt scrolling, the collision is perfect (can only collect it when the player is touching the item). When the game is scrolling (background, ground, and platforms move down), you can collect the item just by being above it (and not touching), you cant collect it by being beside it though.
2. I can't seem to be able to reset the platform heights to it's pre-start state. I can set the ground height (which is connected to the platform height), the background and player so it looks like its restarting, but the platforms just wanna stay where they were before i told everything to stop (when game over'd, I stopped them).
3. I dont really understand how to set up a txt file so that my platform dimensions and item locations are read and implemented correctly in-game.
4. I dont know enough turing to actually know if they way im using some things are correct or good programming. I'm pretty sure there are some things I can improve though (could you guys give me some pointers?).
5. One more problem: I'm using BSprites as my player and when i am somewhat near the edges of the screen (any platform on either side of the screen), it creates a small tail, but when im in the centre of the screen, it doesnt. How can i fix that?
Describe what you have tried to solve this problem
1. a) I tried changing the collisions detection a bit (but I'm pretty sure they're right cuz when the game is static, it works correctly).
b) Moving when to include the items file
c) Moving other statements around
2. a) Since my platform heights are ground_height + [a value], I assumed that when i set ground_height to what they were before the game, start the scrolling again (ground_height -= scrollingSpeed), the platforms should move right back down to where they began. This only results in the ground to work right, but not my platforms ):
b) Moving around some codes
c) putting the game in a loop, having another loop around that. Exiting the inside loop to repeat the bigger, outside loop again (which should repeat the inside loop again)
3. Reading the tutorial on File I/O, searching on the forums, but i couldnt find a tutorial that explained how to set up the text file.
4. used procedures (not sure if they way I used them are good...)
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
File attached, but I will post the names of the procedures affected so it's easier for you to find it in my turing file (please look at my program, I NEED HELP! D: Project is due on tuesday.. so ye)
Where the item collecting stuff are :
Where the restart level things are:
Turing: |
proc LevelOver
% and in the game loop, starting with:
if retry then
|
Please specify what version of Turing you are using
4.1.1
Sorry this is a long post and that I have a lot of questions
Please answer this before Tuesday since this project is due then.
Description: |
final project.t is the game |
|
Download |
Filename: |
eat the sweets.rar |
Filesize: |
2.7 MB |
Downloaded: |
74 Time(s) |
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
TigerFallOut
|
Posted: Fri Dec 16, 2011 10:49 pm Post subject: Re: Collecting items and restarting level, and using txt files for loading in a level in vertical-scrolling platformer |
|
|
Oops, the version of "final project.t" was the one that scrolled up a bit when you're near the top of the screen one. Attached is the scrolling one (the way i want the game to be plus a few problems)
Just place file in the folder you download from my previous post.
btw, dont mind that bar at the top, its just for me see the state of some variables.
EDIT: I fixed problem #1, the collecting item thing. Realized i never told the y2 of the pic to subtract (just moved the y1, so it was creating a huge rectangle that would mean a collision).
But i still need help in restarting the level and using txt files to load my level instead of a turing file.
Description: |
|
Download |
Filename: |
final project.t |
Filesize: |
10.42 KB |
Downloaded: |
79 Time(s) |
|
|
|
|
|
|
Aange10
|
Posted: Sat Dec 17, 2011 5:57 am Post subject: RE:Collecting items and restarting level, and using txt files for loading in a level in vertical-scrolling platformer |
|
|
Quote: 2. I can't seem to be able to reset the platform heights to it's pre-start state. I can set the ground height (which is connected to the platform height), the background and player so it looks like its restarting, but the platforms just wanna stay where they were before i told everything to stop (when game over'd, I stopped them).
If you're just resetting everything to how it was before, do just that. Reset all the variables to where they were before.
Quote: 3. I dont really understand how to set up a txt file so that my platform dimensions and item locations are read and implemented correctly in-game.
The basic Idea to this is say I have four variables. It can by the four cordinates of the platform. I'll have turing write to the file like
TEXT FILE wrote:
Platform(1).x =20
Platform(1).y =20
platform(1).x2 =40
platform(1).t2 =40
Now this set up makes it easy for me to manually read the file too. Because I know what everything is, and its not encrypted. (Later you could encrypt it, or whatever you like).
Now I can continue on and have Turing get the information and store it (I take it you know how to do this. If you don't visit I/O in the Turing Walkthrough).
The fun part is in the string manipulation (also found in the walkthrough). Pretty much all we need to do is go through the string untill we find an '='. Then after that = is whatever our variable value is. Get it?
I was unable to recreate your fifth problem =( Sorry
Hope that helps! =)
|
|
|
|
|
|
TigerFallOut
|
Posted: Sun Dec 18, 2011 4:40 pm Post subject: RE:Collecting items and restarting level, and using txt files for loading in a level in vertical-scrolling platformer |
|
|
thanks! I'll go look into those tutorials again and see if i can understand what to do
|
|
|
|
|
|
Aange10
|
Posted: Sun Dec 18, 2011 6:15 pm Post subject: RE:Collecting items and restarting level, and using txt files for loading in a level in vertical-scrolling platformer |
|
|
Np! And sorry for all the mistypes haha.
|
|
|
|
|
|
|
|