Computer Science Canada Platformer (Climber) |
Author: | Aange10 [ Wed Oct 12, 2011 3:26 pm ] |
Post subject: | Platformer (Climber) |
Not sure whether to post this Alpha in the help forum or here. So I put it here. I'm making a game with a friend just to put everything I've learned together, and make something I'm proud of. I'm posting this here to ask a few questions, and get some key feedback: 1. Do you see any flaws? 2. Is the coding messy/repetitive/inefficient? 3. Is the game's collision too messy? 4. Is 3. easily noticeable? 5. Do you have any suggestions to add (no flaming/sarcasm please)? 6. Any links you think would benefit me? 7. Did you like this first level? (It's an intro "level") NOTE: This is not the full game, nor is it close to the final product. This is just testing the collision/graphics engine of the game, and the omniscient narrations. If you'd like your name on the credits list, comment below! |
Author: | Zren [ Wed Oct 12, 2011 11:04 pm ] | ||||||||
Post subject: | RE:Platformer (Climber) | ||||||||
Okay, that should get you started, but I doubt that's everything. ~ If you get the "not nuff mem to indent file" because you've got lines longer than x chars, you can do:
~ Your types need work. Typically you do player.x or platform.w instead of platform.plat_width. I remember reading this in another thread I think. If you want to change it in this code, backup the file then use Search > Replace .var -> .newvar and click replace all. ~
Why'd you make a whole extra array (plat_height)? Also, hardcoding values will be a pain no matter what. Consider loading platforms from a text file (x,y,w,h). Check out the example given for flexible for loading in a unknown size of data. Once you've gotten that, you can just edit the data in that text file _or_ you could create a level editor! That saves platforms to an array on a mouse click - drag - release. With a save button that will save to your platform.txt format. ~ You've hardcoded the number 12 a few times. What's it's significance? ~
That has to be the worst implementation of toggling a boolean I've ever seen. Why in gods name is there a loop? ~ I'd move the collision detection to a function that returns a boolean personally. That way I could just use something like: fcn collision(a, b:Rect) :boolean result a.x + a.w ..... ~ I'd also move the common variables from both of your types to a subtype. Both platform and player types are rectangles, so I'd give it it's own rect type, then have each of the super-types have it's own r:Rect instead of their own w,h,x,y variable. ~ Example pulled from old code.
|
Author: | Aange10 [ Thu Oct 13, 2011 12:11 am ] | ||||||
Post subject: | Re: Platformer (Climber) | ||||||
Zren wrote: Okay, that should get you started, but I doubt that's everything. ~ If you get the "not nuff mem to indent file" because you've got lines longer than x chars, you can do:
Alright, good to know. But I can indent my own code, so do you think it'd be smarter to do that? I personally think that having it in different lines for one command is ugly. Zren wrote: Your types need work. Typically you do player.x or platform.w instead of platform.plat_width. I remember reading this in another thread I think. If you want to change it in this code, backup the file then use Search > Replace .var -> .newvar and click replace all. Wow. I can't believe i didn't notice the redundancy. Thankyou, fixed! Zren wrote:
Why'd you make a whole extra array (plat_height)? Also, hardcoding values will be a pain no matter what. Consider loading platforms from a text file (x,y,w,h). Check out the example given for flexible for loading in a unknown size of data. Once you've gotten that, you can just edit the data in that text file _or_ you could create a level editor! That saves platforms to an array on a mouse click - drag - release. With a save button that will save to your platform.txt format. I don't know why i didn't realize i could implement it into the data record. Fixed! As for player maps, that is really an excellent idea!It sounds awesome, and thank you for telling me how to go about it! But what makes it more effective to put the coding in a txt file? Accessibility? (When not planning on a map editor) Zren wrote: You've hardcoded the number 12 a few times. What's it's significance? This is because my collision isn't perfect, so i use it as a "grace" period at which my character may be by the box and it be considered collision. 12 because 12 + 12 was 24 and that's close to my character's height with 2 pixles above & below as margin for error. [Old thinking, really. Now that i think about it, that argument doesn't really matter too much] If you have a suggestion/link/explanation/tutorial/fundamental or any other piece of advise i can analyze to make my collision perfect, PLEASE show me. I have read the perfect circle collision. Zren wrote:
That has to be the worst implementation of toggling a boolean I've ever seen. Why in gods name is there a loop? Fixed after looking up the not command in the turing reference. Sorry didn't know it did that. Zren wrote: I'd move the collision detection to a function that returns a boolean personally. That way I could just use something like: fcn collision(a, b:Rect) :boolean result a.x + a.w ..... Well considering my grace i have in affect, I need to teleport my character ontop of the platform so he's not hovering. (I know don't yell, i'm trying to get it perfect) If you notice i do have most of my collisions pass booleans aswell, it makes it easier if i need to know about it later. Zren wrote: I'd also move the common variables from both of your types to a subtype. Both platform and player types are rectangles, so I'd give it it's own rect type, then have each of the super-types have it's own r:Rect instead of their own w,h,x,y variable. Oh you mean like classes? Polymorphism, i think is what it's called. Parent class [well record in this case] Rectangle, then child classes player & platform? ~~~~~~~ Thank you so much for the critiquing, Zren! This is exactly the kind of help i need, and I'm thankful that you've given it to me. Definetly on the soon-to-be-implemented credits list! |
Author: | Aange10 [ Thu Oct 13, 2011 12:21 am ] |
Post subject: | Re: Platformer (Climber) |
Version 0.6 is now released! Changes: ~ Added a bit after the portal ~ Added a stick man as a character instead of a box. (Later will start as a box, and change to a stick man "As the game progresses...") ~ Added in a few more cheats (After implementing the new character, they are broken, however.)- Am planning on implementing new cheats. ~ Fixed up some messy coding with records. ~ Tidied up some redundant coding. - Planning on implementing Saving |
Author: | Tony [ Thu Oct 13, 2011 1:02 am ] | ||||||||||||||
Post subject: | RE:Platformer (Climber) | ||||||||||||||
Reading v0.6
there's an _variable convention that typically means "internal"; sometimes even __variable for some magical variables. Underscore at the end seems like an odd naming choice. chars2 is declared but is not used.
followed right after with
confusing. Boolean variables can be used directly in conditionals. Instead of
you can simply say
The entire proc free_pics is not needed (and is not used anyway). If you have just those 3~4 pictures, you can keep them in memory until the program ends. Loading them back and forth is expensive (takes time). Freeing resources is important when you dynamically create and load a lot of new ones, but this is not the case. player_clip_1, player_clip_2, ..., player_clip_6 this should scream "use an array", and it would be right.
plat_height sounds like it belongs to Platform_data
separation of code and data! This kind of stuff (map data) belongs in a map file. You could then just read the values in from a loop. |
Author: | Aange10 [ Thu Oct 13, 2011 4:41 pm ] | ||||||||||||
Post subject: | Re: Platformer (Climber) | ||||||||||||
Tony wrote: Reading v0.6
there's an _variable convention that typically means "internal"; sometimes even __variable for some magical variables. Underscore at the end seems like an odd naming choice. Fixed. Renamed to fps_timer. Thanks Tony wrote: chars2 is declared but is not used. Made the two variables when i first started the project. Fixed. Tony wrote: Post RE:Platformer (Climber)
followed right after with code:
confusing. My bad, i put it in with a bunch of other variables that were boolean := true, and just made it false. Fixed. Tony wrote: Boolean variables can be used directly in conditionals. Instead of
you can simply say
Hmm interesting, didn't know that. However I think it makes it to put the = true. Is it really necessary to change it? If so I will Tony wrote: The entire proc free_pics is not needed (and is not used anyway). If you have just those 3~4 pictures, you can keep them in memory until the program ends. Loading them back and forth is expensive (takes time). Freeing resources is important when you dynamically create and load a lot of new ones, but this is not the case. player_clip_1, player_clip_2, ..., player_clip_6 this should scream "use an array", and it would be right. Ahh but, not so true D:. I've read in the tutorials it's good practice when using pics to unload them after they are done. I realize the mistake with my range on freeing the pictures, and I've set it to be just below the 2nd "level". Now it will correctly free pics, though do remember you can't go back down, so they won't be loaded back and forth. Alright, pictures are now made into an array. Thanks for the heads up! Tony wrote: plat_height sounds like it belongs to Platform_data
separation of code and data! This kind of stuff (map data) belongs in a map file. You could then just read the values in from a loop. First problem is fixed. 2nd: Yes, I guess I'll look into indexing and pointers. D: . I know I also need to implement a save system. ..... Thanks a ton for your critiquing(:! If you see anything else please don't hesitate to let me know! |
Author: | Tony [ Thu Oct 13, 2011 5:27 pm ] |
Post subject: | Re: Platformer (Climber) |
Aange10 @ Thu Oct 13, 2011 4:41 pm wrote: Hmm interesting, didn't know that. However I think it makes it to put the = true. Is it really necessary to change it? If so I will A lot of the points are more in terms of style and software engineering practices. Is it necessary? No. But I think it improves readability of the code. |
Author: | Raknarg [ Thu Oct 13, 2011 7:38 pm ] |
Post subject: | RE:Platformer (Climber) |
Does it really? Js, to me it makes more sense to add the = true after so you know it's a boolean, a lot like you would put a string after a string and a number after a number |
Author: | Tony [ Thu Oct 13, 2011 7:47 pm ] | ||
Post subject: | RE:Platformer (Climber) | ||
only when it comes to literal values. If you have code like
then you can't infer the type of either variable. So it comes down to a naming convention. You can assume that name_of_sheep and num_of_sheep are string and integers. Similarly you can figure that is_a_sheep is boolean. Ruby has a neat convention of ending function names with a question mark to denote that they return a boolean value. |
Author: | Raknarg [ Thu Oct 13, 2011 7:58 pm ] |
Post subject: | RE:Platformer (Climber) |
I suppose thats true |
Author: | Aange10 [ Fri Oct 14, 2011 11:12 pm ] |
Post subject: | Re: Platformer (Climber) |
Version 0.7 Is now released! Getting closer to the official release; 1.0! Changes: ~ Cleaned up a bit more redundant code ~ Now correctly freeing recources via Pic.Free ~ Fixed some spelling on the cheat codes ~ Redesigned the admin cheat ~ Fixed source code variable typos ~ Implemented Saving and Loading systems based off your user name. ~ Graphics for the buttons! Whats to Come: ~ A feature to remember the last username entered, and ask if that player is you. ~ A feature to show all your saves ~ Many more gameplay/levels ~ Many more working Cheat Codes ~ Witty narrorations and more graphical gameplay and characters. ~ Minor bug fixes ~ [Hopefully] A new physics engine ~ Intro screen/Story ~ Idle animations, interactive backgrounds, and MUCH MUCH more(: Stick Around! |
Author: | Raknarg [ Sat Oct 15, 2011 10:13 am ] |
Post subject: | RE:Platformer (Climber) |
What I thought was interesting was how you made it so that your animations don't have the annoying white box around them, which is why I now only use turing drawing functions. How did you accomplish that? |
Author: | Aange10 [ Sat Oct 15, 2011 10:26 am ] |
Post subject: | RE:Platformer (Climber) |
picMerge will accomplish that(: |
Author: | Aange10 [ Sun Oct 16, 2011 12:12 am ] |
Post subject: | Re: Platformer (Climber) |
I feel very productive to be coming out with new versions so rapidly(: . However, do know that the next version will be a game content expansion, so expect an extended amount of time before its release! But now let me interest you in Platformer V0.8! Changes ~ Fixed collision bug with the first platform ~ Now saves in Data files instead of Txt files. ~ Fixed coding bug ~ The Douggie(: ~ Recommended Usernames (Saved Files) ~ Cleaned Variables ~ Appropriate storing of files ~ Massive improvement of physics engine ~ Full Commenting ~ Flying Cheat ~ Case proofed all cheats |
Author: | Aange10 [ Tue Oct 18, 2011 7:17 pm ] |
Post subject: | Re: Platformer (Climber) |
Aange10 wrote: I'm making a game with a friend just to put everything I've learned together, and make something I'm proud of. I'm posting this here to ask a few questions, and get some key feedback: I think I have definitely achieved this. I'm very happy to have programmed this little game. I've learned many concepts making this game. However, one very important aspect to a game is the graphics designer. Unfortunately, my graphics designer has let me down. I have nearly-zero interest in drawling pictures, I only care about the coding. As a result of undependability on my friends half, there won't be new game content added. Which sadly means this is more of a "I enjoy seeing the coding work" than a "I enjoy playing" game. Albiet not adding new game content, I'm happy to release the Official 1.0 Version! If you find any bugs, or any place to critique me, please let me know. I'd be more than happy to fix these bugs/inefficiencies. If you have any suggestion on something to add to the already existing game, do let me know, as I'd be happy to add neat things or play with alien concepts. But, now without further ado, let me introduce you to Platformer! Final-Edition Changes: ~ Fixed bug where being on the username page too long made you Douggie ~ Added a disclaimer on the cheat codes ~ Login rememberer now properly remembers names with spaces ~ Implemented new platforms ~ Credits ~ Added two custom platforms |
Author: | Beastinonyou [ Tue Oct 18, 2011 10:17 pm ] | ||||
Post subject: | Re: Platformer (Climber) | ||||
I guess I'm the first to notice this, and post it. People won't even get past the credits. I'm going to leave it for you to figure it out, but it is very obvious given the error message:
Error Message: Cannot Allocate Item. Out of id numbers (max 1000) Any idea as to why you get that error? I know why =P Also, after playing the game past the credits (after i modified your above code to get past the credits), I receive the same error moments later in the second map, hint: Your exact same problem as above, occurs in the following procedure.
As an observation, am I supposed to only reach the second map? and maybe you should move the Credits to the end of the game, or have a button that runs that for credits, rather than waiting 30 seconds before the program starts to run. =D |
Author: | Aange10 [ Wed Oct 19, 2011 4:30 pm ] | ||||
Post subject: | Re: Platformer (Climber) | ||||
Beastinonyou @ 18/10/2011, 9:17 pm wrote: I guess I'm the first to notice this, and post it.
People won't even get past the credits. I'm going to leave it for you to figure it out, but it is very obvious given the error message:
Error Message: Cannot Allocate Item. Out of id numbers (max 1000) Any idea as to why you get that error? I know why =P Also, after playing the game past the credits (after i modified your above code to get past the credits), I receive the same error moments later in the second map, hint: Your exact same problem as above, occurs in the following procedure.
=D Hmm, I'm not sure. If I could re create the error, I could probably fix it. The only thing I know of that involves a 1000 limit is pictures... Which my text has nothing to do with. Everything works perfectly fine for me. Do you have any idea why both of these are flawless on my computer, and my school's computer, but do not work on yours? Also Beastinonyou wrote: As an observation, am I supposed to only reach the second map? and maybe you should move the Credits to the end of the game, or have a button that runs that for credits, rather than waiting 30 seconds before the program starts to run. I doubled the speed, but I want to keep it at the front. I want people to see those who helped a lot |
Author: | Tony [ Wed Oct 19, 2011 4:48 pm ] |
Post subject: | Re: Platformer (Climber) |
Aange10 @ Wed Oct 19, 2011 4:30 pm wrote: on my computer, and my school's computer, but do not work on yours?
Resolution, window size, fonts available to the system... "but it works on _my_ computer" is more of an industry's inside-joke than a legitimate excuse. Aange10 @ Wed Oct 19, 2011 4:30 pm wrote: I want people to see those who helped a lot
That's a nice gesture, but typically games do keep credits at the end. I think some games choose non-blocking methods, such as making a message be a part of the level itself. Basically -- making players wait is bad news; reminds me of http://compsci.ca/blog/now-loading-loading-bar-anti-pattern/ |
Author: | Aange10 [ Wed Oct 19, 2011 5:52 pm ] |
Post subject: | Re: Platformer (Climber) |
Tony @ 19/10/2011, 3:48 pm wrote: Resolution, window size, fonts available to the system... I thought about that, but the resolution/window size is pre set, and the fonts are in turing itself...? |
Author: | Tony [ Wed Oct 19, 2011 5:53 pm ] |
Post subject: | RE:Platformer (Climber) |
no, no, and no. |
Author: | Aange10 [ Wed Oct 19, 2011 6:09 pm ] | ||
Post subject: | RE:Platformer (Climber) | ||
Doesn't set the screen size to 700x 500y? ... And how do i go about fixing the bug if I can't recreate it to test solutions |
Author: | Tony [ Wed Oct 19, 2011 6:17 pm ] |
Post subject: | Re: RE:Platformer (Climber) |
Sure, but is the window resizable by the user? If so, it could be stretched much further on a system running at a larger resolution that yours. Aange10 @ Wed Oct 19, 2011 6:09 pm wrote: And how do i go about fixing the bug if I can't recreate it to test solutions
That is indeed a problem. |
Author: | mirhagk [ Wed Oct 19, 2011 6:22 pm ] | ||
Post subject: | RE:Platformer (Climber) | ||
Well there is a key fundamental problem that we can all see, fixing that issue does not require compiling it, it requires looking at the error message, and the code. I'll tell you what line it's on (haven't run the code but I'm pretty sure)
|
Author: | Beastinonyou [ Wed Oct 19, 2011 6:24 pm ] | ||
Post subject: | Re: RE:Platformer (Climber) | ||
mirhagk @ Wed Oct 19, 2011 6:22 pm wrote: Well there is a key fundamental problem that we can all see, fixing that issue does not require compiling it, it requires looking at the error message, and the code. I'll tell you what line it's on (haven't run the code but I'm pretty sure)
Precisely =P |
Author: | mirhagk [ Wed Oct 19, 2011 6:30 pm ] |
Post subject: | RE:Platformer (Climber) |
Also I can tell you why Beastinyou came across it and you didn't. And it's not resolution, it's the fact that he saw the credits twice. Again, can't say for sure, but it's an educated guess. |
Author: | Beastinonyou [ Wed Oct 19, 2011 6:42 pm ] | ||
Post subject: | Re: Platformer (Climber) | ||
If I May Elaborate, You get the exact same error in this Situation:
This should give you a giant clue..... |
Author: | Aange10 [ Wed Oct 19, 2011 7:27 pm ] |
Post subject: | Re: Platformer (Climber) |
Fixed? and Tony wrote: Aange10 @ Wed Oct 19, 2011 6:09 pm wrote: And how do i go about fixing the bug if I can't recreate it to test solutions
That is indeed a problem. I take it there is no way, then. I guess that's why there are testers |
Author: | Tony [ Wed Oct 19, 2011 7:36 pm ] |
Post subject: | RE:Platformer (Climber) |
It might just take a lot more effort to reproduce such a bug. A bug could potentially happen only on a specific hardware/OS/3rd-party-software combination -- such an environment could be acquired (virtualization makes this cheaper, though still very time consuming), though typically it is not feasible to test through all of the possible permutations. Heisenbug (such as problems with the compiler or certain cases when dealing with concurrency) are a lot more interesting. http://en.wikipedia.org/wiki/Unusual_software_bug#Heisenbug Quote: A heisenbug (named after the Heisenberg Uncertainty Principle) is a computer bug that disappears or alters its characteristics when an attempt is made to study it. |
Author: | Beastinonyou [ Wed Oct 19, 2011 8:56 pm ] | ||||||||||
Post subject: | Re: Platformer (Climber) | ||||||||||
I see you've changed a few things, such as moving the font declarations to the top, and using a couple Font.Free()'s in there. However, 34 Seconds from the time I entered my Username, and Was able to move the Character, I come to the same error.
Firstly, I notice there's no 's' on the end of Time, so I'm not sure if that will even set the font it properly. However, this isn't the major issue. Might I suggest, that rather than changing a font over and over, multiple times (even if you are using Font.Free), in a loop, Wouldn't it be Much Much more simpler to make a couple fonts at the beginning. Example: You are (Correct me if I'm wrong) doing this (essentially, in regards to the fonts):
You could do this instead:
Now, say you didn't want to write those boring Declaration lines for the font's, you could do this:
Aside from this, I Advise organizing your code in a more readable manner, and grouping certain things together. Variables related to a certain thing should be grouped with other variables involved with that same thing. Cramming your variables into one declaration line may seem to be nice by saving Lines, but it's much more easily readable, to find your variables. I also notice that for the majority of the programming, there are rarely spaces, sometimes two lines with "%", but it doesn't make it a whole lot clearer. Try to separate some of the Structures a bit more. Lastly, I would like to ask why is it that you are Freeing your Pictures at all? You only have: 15 Pictures; 5 of Scenery, and 10 of your Character. At Most, this should be 15 declarations for your pictures. You don't have to Free stuff, if you aren't having your photo's repeatedly loading. You only need 15 slots (out of what? 1000?) Declare your pictures Outside of your Loop for your Main Program, Therefore not constantly being loaded, and not needing to be Freed. You could hardcode each declaration line for all your pictures, or use an array and a For repetitive structure to initialize those pictures with numbers on the end. Let me end off on this long post I've spent the last hour on, while watching Episode 3 of Dexter (S.6), and Currently, Penn & Teller: Tell A Lie
|
Author: | Aange10 [ Wed Oct 19, 2011 9:41 pm ] |
Post subject: | Re: Platformer (Climber) |
beastinonyou wrote:
I feel fail for missing that line. Also for the misspelling. The font thing.. Genius! I can't believe I didn't think of that. Excellent! Thankyou! Fix? |
Author: | Beastinonyou [ Wed Oct 19, 2011 9:58 pm ] | ||||
Post subject: | Re: Platformer (Climber) | ||||
I No Longer Crash ... Which is a good thing =P However, One thing I might remind you:
With all your Picture Declarations near the top of the program, you don't need all those "freed" lines, just draw the pics. (and also no need for those other picture declarations in there.) Heck, I think you can just junk the entire "FreePics" procedure, because you've already gotten all the pictures you need, and there is no need to be freeing them repeatedly. This is how I might edit it:
|
Author: | Aange10 [ Wed Oct 19, 2011 10:18 pm ] |
Post subject: | Re: Platformer (Climber) |
Beastinonyou @ 19/10/2011, 8:58 pm wrote: I No Longer Crash ... Which is a good thing =P
and there is no need to be freeing them repeatedly. It's not freeing them repeatedly. I'll take it out if necessary, but isn't it good to practice freeing your pics? It's not repeatedly freeing them because it frees the bottom pictures (after u go through the portal) if you go above the purple platform. You can't go back down. (Unless you Admin cheat). Isn't this conserving space? I realize that I don't have 1000 pictures, but that shouldn't prevent me from freeing picks after a certain point? Or should it? Tony said the same thing you did, could you please elaborate on why it's not good? (Other than the program being small.) |
Author: | Beastinonyou [ Wed Oct 19, 2011 10:34 pm ] |
Post subject: | Re: Platformer (Climber) |
Freeing your pictures should be used when necessary, like in the instance that you are using many, many images. In your situation, with a mere 15 pictures, freeing them to conserve space, is just more coding that doesn't need to be coded. Somewhat of an Analogy - You have a gun with 1,000 bullets, and you're reloading after you fire off <15 bullets. Not sure if it's a proper analogy, but it doesn't really make sense if you're reloading after 15 bullets, if you have 1,000, and say "Just in case I don't run out" |
Author: | Aange10 [ Wed Oct 19, 2011 10:53 pm ] |
Post subject: | RE:Platformer (Climber) |
Well, is it not good coding practice? I took me less than 10 minutes to code that. I want to make everything run right, and even better. 10 minutes is not much for something so appeasing. And it's easy to add new pictures. If I continued to expand, I would have a system to conserve space. And it's more like if quick writing an essay. Yeah I don't need to think recursively to write the paper, a linear approach would be just fine. But if it was a real essay I would need to. I'm not losing anything by practicing my writing skills. |
Author: | Tony [ Wed Oct 19, 2011 11:10 pm ] |
Post subject: | RE:Platformer (Climber) |
It adds complexity, which in software typically leads to bugs. To be exact, you are manually keeping track of specific pictures, specific player locations/boundaries, and a bunch of flag/state variables. You essentially have resource, data, and logic duplication between proc free_pics and the rest of your program. You make a good point about coding practice -- I would suggest thinking about a procedure to load/unload an abstract level. Something general enough to work for any level (current and future), so no reference to any specific resource by name. |