Author Topic: Physics Tilemapper  (Read 6570 times)

0 Members and 1 Guest are viewing this topic.

Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
Physics Tilemapper
« on: January 21, 2011, 12:06:35 am »
I've thought about it for a long time, but I can't figure out how to do it. How do you make a tilemapper scroll both horizontally and vertically but retain physics elements like gravity?
Sample code would be nice.
Thanks in advance.
In-progress: Graviter (...)

Offline Masinini

  • LV2 Member (Next: 40)
  • **
  • Posts: 33
  • Rating: +0/-0
    • View Profile
Re: Physics Tilemapper
« Reply #1 on: January 21, 2011, 04:35:16 pm »
I have never done this personally. So I'm just gonna post what I would do. I would have your character in the middle of the screen, and stay there. When you move, the screen scrolls, instead of you actually moving. Then, when your guy falls, he just need to scroll when he falls, and add in code so he can move sideways. If this seems, confusing, sorry, but it's the simplest way that I could figure through my limited experience.
Output(1,1,"By the pricking of my thumb"
Txt(1,1, "Something wicked this way comes."

Ashbad

  • Guest
Re: Physics Tilemapper
« Reply #2 on: January 21, 2011, 04:40:30 pm »
I can say a few things, though codewise it's not like a little thing; it could be dozens and dozens of lines just for the mapper/configurer.  But I can give some hints:

- Don't use horizontal/vertical commands, they are VERY slow; use an offset as a way of scrolling instead.
- While scrolling with your char moving around the screen at the same time is very nice, it can be slow too, and very complicated.  Don't take that on unless you really know what you're doing.
- For collision detection (and for the physics part) I'm sure you'll use velocities to move the character, like if the Y velocity is 2 then the character moves down 2 pixels next redraw.  Use a For(Var, 0, amount of pixels you'll move) statement to check all possible positions along the way of the movement and to also make sure you don't fall through floors when you move at increments of more than one pixel at a time.

Offline Binder News

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 785
  • Rating: +46/-3
  • Zombie of Tomorrow
    • View Profile
Re: Physics Tilemapper
« Reply #3 on: January 21, 2011, 04:41:54 pm »
Attached is the source for my solution to the problem.
I wrote it for the game I'm working on, but you can use it, just credit me.
Spoiler For userbars:







Hacker-in-training!   Z80 Assembly Programmer     Axe Programmer
C++ H4X0R             Java Coder                           I <3 Python!

Perdidisti ludum     Cerebrum non habes

"We are humans first, no matter what."
"Fame is a vapor, popularity an accident, and riches take wings. Only one thing endures, and that is character."
Spoiler For Test Results:





Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
Re: Physics Tilemapper
« Reply #4 on: January 21, 2011, 06:02:16 pm »
kthx all. I'm viewing this more of a challenge than an actual project, though if I get it i'll use it in Graviter.
In-progress: Graviter (...)

Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
Re: Physics Tilemapper
« Reply #5 on: January 21, 2011, 07:09:58 pm »
I was thinking more of something along the lines of tloz's platformer:
http://www.omnimaga.org/index.php?action=dlattach;topic=4479.0;attach=3319

I'm going to examine the code and try to understand it more.
In-progress: Graviter (...)

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Physics Tilemapper
« Reply #6 on: January 22, 2011, 03:10:29 am »
- Don't use horizontal/vertical commands, they are VERY slow; use an offset as a way of scrolling instead.

Correct me if i'm wrong, but I believe there is tilemapper posted in the tilemapper thread by Runner that used horizonal and vertical commands that got 60 FPS :)

Regular 8x8 monochrome seems to work pretty fast for me. I get about 60 fps scrolling for the most part (about 75 for aligned vertical scrolling). The screen is updated after every arrow key has been checked and the buffer image has been scrolled for each pressed key.



Offline Binder News

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 785
  • Rating: +46/-3
  • Zombie of Tomorrow
    • View Profile
Re: Physics Tilemapper
« Reply #7 on: January 22, 2011, 10:10:23 am »
Yup, however, I don't really get his code (It can be kinda weird), and it doesn't have physics.
Spoiler For userbars:







Hacker-in-training!   Z80 Assembly Programmer     Axe Programmer
C++ H4X0R             Java Coder                           I <3 Python!

Perdidisti ludum     Cerebrum non habes

"We are humans first, no matter what."
"Fame is a vapor, popularity an accident, and riches take wings. Only one thing endures, and that is character."
Spoiler For Test Results:





Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
Re: Physics Tilemapper
« Reply #8 on: January 22, 2011, 12:53:22 pm »
So would using horizontal and vertical, then filling in the missing tiles be faster than regenerating the map every frame? what's the most optimized method?
In-progress: Graviter (...)

Offline Binder News

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 785
  • Rating: +46/-3
  • Zombie of Tomorrow
    • View Profile
Re: Physics Tilemapper
« Reply #9 on: January 22, 2011, 02:48:11 pm »
If you're going for size, regenerate the map every frame. However, doing that means that the bigger the map, the longer it takes to draw. (That's only if you are drawing the whole map. If you find a way to only draw the tiles which are on-screen, it would be faster).

The fastest way (I think) would be to use Horizontal and Vertical, then fill in the missing tiles.
Spoiler For userbars:







Hacker-in-training!   Z80 Assembly Programmer     Axe Programmer
C++ H4X0R             Java Coder                           I <3 Python!

Perdidisti ludum     Cerebrum non habes

"We are humans first, no matter what."
"Fame is a vapor, popularity an accident, and riches take wings. Only one thing endures, and that is character."
Spoiler For Test Results:





Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Physics Tilemapper
« Reply #10 on: January 22, 2011, 02:56:09 pm »
I believe Runner posted the source to his program in a different point in that topic so you could check it out or even ask him if you could use it :D

Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
Re: Physics Tilemapper
« Reply #11 on: January 22, 2011, 06:07:26 pm »
Okay, I don't get the code (This is from tloz's tilemapper) attached in the word document - If someone could elucidate that would be great.
In-progress: Graviter (...)

Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
Re: Physics Tilemapper
« Reply #12 on: January 24, 2011, 02:19:18 am »
Okay, I made one using BuilderBoy's algorithm and mapping it every single frame. It's acceptable on full, but lags on normal.
Run DRAW.8xp, the rest are source.
« Last Edit: January 24, 2011, 05:43:46 pm by leafiness0 »
In-progress: Graviter (...)

Offline leafy

  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1554
  • Rating: +475/-97
  • Seizon senryakuuuu!
    • View Profile
    • keff.me
Re: Physics Tilemapper
« Reply #13 on: January 24, 2011, 05:42:52 pm »
Sorry about the triple post (My bad) but I'm still kind of confused as to how to do tile detection for collisions with platforms. I'll attach my attempts (first value x+z, second value y+theta, third value collision tile value) also you need the dependencies in the previous post to compile. If anybody could help that would be great.
In-progress: Graviter (...)