Author Topic: [tutorial] Program Flow - Platformer  (Read 29994 times)

0 Members and 1 Guest are viewing this topic.

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6266
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: [tutorial] Program Flow - Platformer
« Reply #30 on: March 21, 2010, 06:40:42 pm »
oops thanks, the V one should store to V
/e

Offline Gale

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 115
  • Rating: +1/-0
  • Ti-84+ Silver Edition
    • View Profile
Re: [tutorial] Program Flow - Platformer
« Reply #31 on: March 21, 2010, 06:55:26 pm »
oops thanks, the V one should store to V

you made the same mistake in the other part of that section too :P
and thanks again for this awesome guide!
remember me as a time of day...

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6266
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: [tutorial] Program Flow - Platformer
« Reply #32 on: March 21, 2010, 06:58:02 pm »
lol oops x.x
np :)
/e

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: [tutorial] Program Flow - Platformer
« Reply #33 on: March 22, 2010, 10:43:19 pm »
Map data format:
The data uses run length encoding for comression.  Lets say we had a simple map:

Code: [Select]
11111000001111
00000222220000

Pretty simple, each number representing a different tile.  With normal storage this would take
a single byte per tile.  Or we could represent the data in a different way:

Code: [Select]
150514052504
Seems much smaller, but what does it mean?  lets insert some imaginary commas and dashes to make
it easier:

Code: [Select]
1-5,0-5,1-4,0-5,2-5,0-4
Now you may or may not be able to see how the data is represented.  The first segment is 1-5, or 5 '1's in
a row, followed by 0-5, or five '0's in a row, and so on.  This is how the data in run length encoding is
represented.  And to further the compression (or confusion), each #-# segment is packed into a single byte.
Instead of two hex digits to represent a number from 0-255, we will have 2 hex digits, each from 0-15,
representing the two numbers of each #-# element.

The first Hex digit 0 to 15 is the tile number.  The second hex digit is the number of tiles to add to the
tilemap.  The digit goes from 0-15, but 0 doesnt make much sense, since that would mean this element doesnt
do anything :P, so we will add one to this after we decompress it so that it has a range of 1 to 16. 

There is a small disadvantage that if you have empty spaces of 17 or more in a row, it will take more than
1 byte to represent in the code.

Decompressing the Map:

Code: [Select]
[Data]->GDB1 //map data to GDB1
[tileData]->Pic1 //tile data for tilemap

0->N //element index for map data
0->I //map index for storing tile data

While I>=96 //until we have stored all tiles
{GBD+N}->A //Take the first element of the map data
N+1->N //Increment the map index
A^16->B //spit the map element into it
A/16->A two seperate elements

For(F,0,B //fill the map from current position I to I+B
A->{L1+I} //could be optimised with Fill but i couldnt get it
I+1->I //working :/
End

End //End while

After this code is run, the tile data will be decompressed into L1, as folows

Code: [Select]
0  1  2  3  4  5  6
7  8  9  10 11 12 13...

ect, it will be in a straigt line, but you will have to access it using your own routine.  Something like this

Code: [Select]
{Y*W+X+L1}
where W is the width in tiles of your map.  X and Y would be the tile coordinates starting at the top left at
0,0.


Displaying the map:

here is a rudimentary program that should be run right after the pervious decompressing program:

Code: [Select]
For(X,0,11 //loop through the entire screen coordinates with tiles of 8x8
For(Y,0,7
{Y*12+X+L1}->A //retrieve the correct tile from the data in L1
Pt-On(X*8,Y*8,A*8+Pic1 //draw the sprite to the screen
End
End



Also attached is a PEDIT program to create and compress maps into a Hex String into Str1, as well as an Axe program to decompress and display them.  Just put the string data into GDB1

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6266
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: [tutorial] Program Flow - Platformer
« Reply #34 on: March 22, 2010, 11:41:05 pm »
Edit, thanks. I'll add it in.
/e

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: [tutorial] Program Flow - Platformer
« Reply #35 on: March 22, 2010, 11:45:58 pm »
Woot, although it would be nice if for the code segments there were line breaks between each line :) it would make it a bit easier to read.

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6266
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: [tutorial] Program Flow - Platformer
« Reply #36 on: March 22, 2010, 11:55:10 pm »
Lol, np, already done :p and I know I didn't end the code segment in the right place...but it's so hard to edit that post on my iPod x.x I don't want to go through tat again, I'll fix it tomorrow.
/e

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: [tutorial] Program Flow - Platformer
« Reply #37 on: March 22, 2010, 11:56:18 pm »
Ah, yeah that would be hell.  It looks good though :) html and all ^^

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6266
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: [tutorial] Program Flow - Platformer
« Reply #38 on: March 23, 2010, 12:06:11 am »
It was x.x
thanks :) hmm, I should do a tutorial on how to make that type of HTML :p just some simple css styling of <div> blocks :p
/e

Offline ikemike

  • LV3 Member (Next: 100)
  • ***
  • Posts: 67
  • Rating: +4/-0
  • Hmm.
    • View Profile
Re: [tutorial] Program Flow - Platformer
« Reply #39 on: March 23, 2010, 06:57:59 pm »
Can somebody make a basic platformer using this code? If I had an premade example to work from, it'd help my comprehension of the tutorial.
Anonymous Legend

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6266
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: [tutorial] Program Flow - Platformer
« Reply #40 on: March 23, 2010, 07:03:41 pm »
Sure, I'll do that.
/e

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: [tutorial] Program Flow - Platformer
« Reply #41 on: March 23, 2010, 07:27:30 pm »
mhmm it might be a good idea to have an example, actually, with maybe a screenshot. Some people are more visual. (like me)

Offline Gale

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 115
  • Rating: +1/-0
  • Ti-84+ Silver Edition
    • View Profile
Re: [tutorial] Program Flow - Platformer
« Reply #42 on: March 23, 2010, 07:31:34 pm »
Sure, I'll do that.
thank you :D i was thinking the exact same thing as DJ and ikemike
remember me as a time of day...

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6266
  • Rating: +318/-36
  • little oof
    • View Profile
    • Eeems
Re: [tutorial] Program Flow - Platformer
« Reply #43 on: March 23, 2010, 07:40:25 pm »
yeah, I'll get on it :)
/e

Offline jsj795

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1105
  • Rating: +84/-3
    • View Profile
Re: [tutorial] Program Flow - Platformer
« Reply #44 on: March 24, 2010, 03:02:43 pm »
Can somebody make a basic platformer using this code? If I had an premade example to work from, it'd help my comprehension of the tutorial.
I'm actually working on BASIC platformer. look at the TLM post. I can also post the movement program, and even attach it if you want


Spoiler For funny life mathematics:
1. ROMANCE MATHEMATICS
Smart man + smart woman = romance
Smart man + dumb woman = affair
Dumb man + smart woman = marriage
Dumb man + dumb woman = pregnancy
2. OFFICE ARITHMETIC
Smart boss + smart employee = profit
Smart boss + dumb employee = production
Dumb boss + smart employee = promotion
Dumb boss + dumb employee = overtime
3. SHOPPING MATH
A man will pay $2 for a $1 item he needs.
A woman will pay $1 for a $2 item that she doesn't need.
4. GENERAL EQUATIONS & STATISTICS
A woman worries about the future until she gets a husband.
A man never worries about the future until he gets a wife.
A successful man is one who makes more money than his wife can spend.
A successful woman is one who can find such a man.
5. HAPPINESS
To be happy with a man, you must understand him a lot and love him a little.
To be happy with a woman, you must love her a lot and not try to understand her at all.
6. LONGEVITY
Married men live longer than single men do, but married men are a lot more willing to die.
7. PROPENSITY TO CHANGE
A woman marries a man expecting he will change, but he doesn't.
A man marries a woman expecting that she won't change, and she does.
8. DISCUSSION TECHNIQUE
A woman has the last word in any argument.
Anything a man says after that is the beginning of a new argument.

Girls = Time * Money (Girls are a combination of time and money)
Time = Money (Time is money)
Girls = Money squared (So, girls are money squared)
Money = sqrt(Evil) (Money is also the root of all evil)
Girls = sqrt(Evil) squared (So, girls are the root of all evil squared)
Girls = Evil (Thus, girls are evil)
*Girls=Evil credit goes to Compynerd255*