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:

Turing:

if true
        and true
        and true
        then
    put "whoa"
end if


~

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.

~

Turing:

plat_height (1) := 50
plat (1).plat_y := (ground_y + ground_height) + plat_height (1)


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?

~

Turing:

proc debug_show
    loop
        if show_debug = false then
            show_debug := true
            exit
        end if
        if show_debug = true then
            show_debug := false
            exit
        end if
    end loop
end debug_show


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.
Turing:

type Point :
    record
        x, y : real
    end record
type Rect :
    record
        x, y, w, h : real
        a, b, c, d : Point
    end record

fcn point (x, y : real) : Point
    var p : Point
    p.x := x
    p.y := y
    result p
end point

fcn rect (x, y, w, h : real) : Rect
    var r : Rect
    r.x := x
    r.y := y
    r.w := w
    r.h := h
    r.a := point (r.x, r.y)
    r.b := point (r.x + r.w, r.y)
    r.c := point (r.x, r.y + r.h)
    r.d := point (r.x + r.w, r.y + r.h)
    result r
end rect

fcn pointInRect (p : Point, r : Rect) : boolean
    result r.a.x <= p.x and p.x <= r.d.x and r.a.y <= p.y and p.y <= r.d.y
end pointInRect

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:

Turing:

if true
        and true
        and true
        then
    put "whoa"
end if



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:

Turing:


plat_height (1) := 50
plat (1).plat_y := (ground_y + ground_height) + plat_height (1)


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:

Turing:


proc debug_show
    loop
        if show_debug = false then
            show_debug := true
            exit
        end if
        if show_debug = true then
            show_debug := false
            exit
        end if
    end loop
end debug_show


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
code:

var time_

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.

code:

var ... sand_free ... : boolean := true

followed right after with
code:

sand_free := false

confusing.

Boolean variables can be used directly in conditionals. Instead of
code:

if sand_free = true then

you can simply say
code:

if sand_free then


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.

code:

var plat : array 1..5 of Platform_data % Platform Record
var plat_height : array 1..5 of int % Distance off the ground

plat_height sounds like it belongs to Platform_data

code:

plat_height(1) := 80
plat_height(2) := 160
plat_height(3) := 230
plat_height(4) := 310
plat_height(5) := 800
plat(1).plat_color := 7
plat(1).plat_x := 220
plat(1).plat_width := 30
plat(1).plat_y := (ground_y + ground_height) + plat_height(1)
plat(1).plat_height := 10
...

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
code:


var time_


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)

code:


var ... sand_free ... : boolean := true

followed right after with
code:
code:

sand_free := false

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
code:

if sand_free = true then


you can simply say

code:

if sand_free then



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

code:


plat_height(1) := 80
plat_height(2) := 160
plat_height(3) := 230
plat_height(4) := 310
plat_height(5) := 800
plat(1).plat_color := 7
plat(1).plat_x := 220
plat(1).plat_width := 30
plat(1).plat_y := (ground_y + ground_height) + plat_height(1)
plat(1).plat_height := 10
...

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
code:

if x == y

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:

Turing:

for i : 0 .. maxy + 300
    var fontt : int := Font.New ("TimesNewRoman:14")
    var y : int := i
    cls
    Font.Draw ("Credits:", maxx div 2 - 5, y, fontt, purple)
    Font.Draw ("I'd like to personally thank,", maxx div 2 - 5, y - 30, fontt, purple)
    fontt := Font.New ("TimesNewRoman:20")
    Font.Draw ("Tony", maxx div 2 - 5, y - 100, fontt, brightred)
    Font.Draw ("And", maxx div 2 - 3, y - 150, fontt, black)
    Font.Draw ("Zren", maxx div 2 - 5, y - 200, fontt, green)
    fontt := Font.New ("TimesNewRoman:14")
    Font.Draw ("Thank you both for all the amazing help!", maxx div 2 - 40, y - 280,fontt, black)
    View.Update
    delay (25)
end for


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.

Turing:

% Draw the outlines / all text
proc drawoutlines


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:

Turing:

for i : 0 .. maxy + 300
    var fontt : int := Font.New ("TimesNewRoman:14")
    var y : int := i
    cls
    Font.Draw ("Credits:", maxx div 2 - 5, y, fontt, purple)
    Font.Draw ("I'd like to personally thank,", maxx div 2 - 5, y - 30, fontt, purple)
    fontt := Font.New ("TimesNewRoman:20")
    Font.Draw ("Tony", maxx div 2 - 5, y - 100, fontt, brightred)
    Font.Draw ("And", maxx div 2 - 3, y - 150, fontt, black)
    Font.Draw ("Zren", maxx div 2 - 5, y - 200, fontt, green)
    fontt := Font.New ("TimesNewRoman:14")
    Font.Draw ("Thank you both for all the amazing help!", maxx div 2 - 40, y - 280,fontt, black)
    View.Update
    delay (25)
end for


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.

Turing:

% Draw the outlines / all text
proc drawoutlines

=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)

Turing:
View.Set ("offscreenonly,graphics:700;500,position:center;center,nobuttonbar")


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)
Turing:

var fontt : int := Font.New ("TimesNewRoman:14")

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)
Turing:

var fontt : int := Font.New ("TimesNewRoman:14")


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:

Turing:

drawfillbox (200, 200, 210, 210, black)
for i : 1 .. 1200
    var picture : int := Pic.New (200, 200, 210, 210)
end for


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.

Turing:

proc drawoutlines
    font2 := Font.New ("TimeNewRoman:20")


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):
Turing:

var font : int := Font.New ("TimesNewRoman:20")
loop    % Main Program
    Font.Draw ("Using Font", 100, 100, font, black)
    font := Font.New ("TimesNewRoman:15")   % Change font
    Font.Draw ("Using Font Altered", 100, 120, font, black)
    font := Font.New ("TimesNewRoman:10")   % Change font again
    Font.Draw ("Using Font Altered Again", 100, 140, font, black)
    Font.Free (font)    % Freeing font
    font := Font.New ("TimesNewRoman:5")    % Changing font again
    cls
end loop


You could do this instead:

Turing:

var fontSize20 : int := Font.New ("TimesNewRoman:20")
var fontSize15 : int := Font.New ("TimesNewRoman:15")
var fontSize10 : int := Font.New ("TimesNewRoman:10")
var fontSize5 : int := Font.New ("TimesNewRoman:5")

loop % Main Program
    Font.Draw ("Using Font Size 20", 100, 100, fontSize20, black)
    Font.Draw ("Using Font Size 15", 100, 120, fontSize15, black)
    Font.Draw ("Using Font Size 10", 100, 140, fontSize10, black)
    Font.Draw ("Using Font Size 5", 100, 150, fontSize5, black)
end loop


Now, say you didn't want to write those boring Declaration lines for the font's, you could do this:

Turing:

var myFontSizes : array 1 .. 4 of int := init (20, 15, 10, 5)% Sizes I want
var font : array 1 .. upper (myFontSizes) of int % Fonts used, retaining to how many size's you've chosen

% Initializes whatever number of font's as the number of Sizes you've chosen
for i : 1 .. upper (myFontSizes)
    font (i) := Font.New ("TimesNewRoman:" + intstr(myFontSizes(i)))
end for

% Draws all the fonts you've initialized
for i : 1 .. upper (myFontSizes) 
    Font.Draw ("Font Size:" + intstr(myFontSizes(i)), 100, 100 + (i * 25), font (i), black)
end for


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

Turing:

% The Other 5 Pictures with no common name
var portal : int := Pic.FileNew ("portal.bmp")
var sky1 : int := Pic.FileNew ("sky1.bmp")
var skyplat1 : int := Pic.FileNew ("sky_plat_1.bmp")
var sand : int := Pic.FileNew ("sand.bmp")
var palmtree : int := Pic.FileNew ("palmtree.bmp")

% Array's to store the picture ID's of Douggie and Player
var douggieClip : array 1 .. 4 of int
var playerClip : array 1 .. 6 of int

% Initialize the 4 Douggie Clips
for i : 1 .. upper (douggieClip)
    douggieClip (i) := Pic.FileNew ("douggie_clip_" + intstr (10 + i)) % Your Douggie Clips count from 10 to 14 (1 to 4( + 10))
end for

% Initialize the 6 Player Clips
for i : 1 .. upper (playerClip)
    playerClip (i) := Pic.FileNew ("player_clip_" + intstr (i))
end for

Author:  Aange10 [ Wed Oct 19, 2011 9:41 pm ]
Post subject:  Re: Platformer (Climber)

beastinonyou wrote:

Turing:

font2 := Font.New ("TimeNewRoman:20")



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:

Turing:

proc free_pics % Preserves memory
    if (player.y - ground_y) >= 799 and palm_free = false then % 799 + from ground
        Pic.Free (palm_tree) % Free pic
        palm_free := true % Set boolean to true
    elsif (player.y - ground_y) <= 798 and palm_free = true then
        palm_free := false
        palm_tree := Pic.FileNew(pic_dir + "palmtree.bmp")
    end if
        %
    if (player.y - ground_y) >= 799 and sand_free = false then
        Pic.Free (sand)
        sand_free := true
    elsif (player.y - ground_y) <= 798 and sand_free = true then
        sand_free := false
        sand := Pic.FileNew(pic_dir + "sand.bmp")
    end if
        %
    if (player.y - ground_y) >= 799 and portal_free = false then
        Pic.Free (portal)
        portal_free := true
    elsif (player.y - ground_y) <= 798 and portal_free = true then
        portal_free := false
        portal := Pic.FileNew(pic_dir + "portal.bmp")
    end if
        %
    for i : 1 .. upper(sky_plat)
        if (player.y - ground_y) >= 1800 and sky_plat(i).freed = false then
            Pic.Free (sky_plat(i).plat)
            sky_plat(i).freed := true
        end if
        if (player.y - ground_y) <= 1780 and sky_plat(i).freed = true then
            sky_plat(i).plat := Pic.FileNew(pic_dir + "sky_plat_1" + ".bmp")
            sky_plat(i).freed := false
        end if
    end for
        %
    if (player.y - ground_y) >= 1800 and stary_sky_free = false then
            Pic.Free (stary_sky)
            stary_sky_free := true
    elsif (player.y - ground_y) <= 1780 and stary_sky_free = true then
            stary_sky_free := false
            stary_sky := Pic.FileNew(pic_dir + "sky1.bmp")
    end if
end free_pics
%
%
proc draw_pics
    % The if statements keep the program from drawing freed pictures
    if palm_free = false then
        Pic.Draw (palm_tree, plat(4).x + 220, plat(4).y + plat(4).h, picXor)
    end if
    if sand_free = false then
        Pic.Draw (sand, plat(4).x, plat(4).y, picXor)
    end if
    if portal_free = false then
        Pic.Draw (portal, plat(4).x, plat(4).y + plat(4).h, picXor)
    end if
    if stary_sky_free = false then
        Pic.Draw (stary_sky, plat(5).x, plat(5).y + plat(5).h, picXor)
    end if
    for i : 1 .. upper(sky_plat)
    if sky_plat(i).freed = false then
        Pic.Draw (sky_plat(i).plat, plat(i + 5).x, plat(i + 5).y, picMerge)
    end if
    end for
   
end draw_pics


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:

Turing:

proc draw_pics
    Pic.Draw (palm_tree, plat(4).x + 220, plat(4).y + plat(4).h, picXor)
    Pic.Draw (sand, plat(4).x, plat(4).y, picXor)
    Pic.Draw (portal, plat(4).x, plat(4).y + plat(4).h, picXor)
    Pic.Draw (stary_sky, plat(5).x, plat(5).y + plat(5).h, picXor)
    for i : 1 .. upper(sky_plat)
        Pic.Draw (sky_plat(i).plat, plat(i + 5).x, plat(i + 5).y, picMerge)
    end for
end draw_pics

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.


: