Author Topic: Some limitations of platformers using pxl-test  (Read 26570 times)

0 Members and 1 Guest are viewing this topic.

Offline nxtboy III

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 795
  • Rating: +26/-1
  • NXT!
    • View Profile
    • Program NXT
Re: Some limitations of platformers using pxl-test
« Reply #30 on: March 15, 2012, 03:33:17 pm »
???
How would that solve it??

I have an integer for the X and Y. I made each pixel divisible by 64, so the X and Y are it's real x and y but multiplied by 64.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Some limitations of platformers using pxl-test
« Reply #31 on: March 15, 2012, 03:35:25 pm »
So the half pixel is 32. Think of this: If you and the enemy are at 0 and you move down 10 and they move up 10, they are now at pixel -1 and you are still at 0. However, if you are both at 32 (the half pixel), you will both cross the pixel boundary at the same time :)

Offline nxtboy III

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 795
  • Rating: +26/-1
  • NXT!
    • View Profile
    • Program NXT
Re: Some limitations of platformers using pxl-test
« Reply #32 on: March 15, 2012, 03:37:56 pm »
Hmm.. Lemme try that.
Post after this so it doesn't count as a double post. :P

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Some limitations of platformers using pxl-test
« Reply #33 on: March 15, 2012, 03:38:35 pm »
Okay, I will ;) I hope it works!

Offline nxtboy III

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 795
  • Rating: +26/-1
  • NXT!
    • View Profile
    • Program NXT
Re: Some limitations of platformers using pxl-test
« Reply #34 on: March 15, 2012, 03:40:16 pm »
AARGGHH!! It doesn't seem to work!!
Why??

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Some limitations of platformers using pxl-test
« Reply #35 on: March 15, 2012, 03:41:50 pm »
I won't be able to make sense of the code, but maybe post the code where velocity and position get updated?

Offline nxtboy III

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 795
  • Rating: +26/-1
  • NXT!
    • View Profile
    • Program NXT
Re: Some limitations of platformers using pxl-test
« Reply #36 on: March 15, 2012, 04:02:17 pm »
I'll just explain it:

Variables you need to know-
X- the x axis of the player
Y- the y axis of the player
VY- Velocity Y axis of player
Xd- The X axis of the map(not really)
Yd- The Y axis of the map(not really)
Ym- How much player moved when going up a diagonal on Y axis
Xdt- version of Xd, before movement
Ydt- version of Yd, before movement
xt- How much the player moved on X axis
yt- How much the player moved on the Y axis
xtt- the X axis of the map divided by -64
ytt- the Y axis of the map divided by -64
ex- Enemy x axis
ey- enemy y axis
ex64- enemy x axis divided by 64
ey64- enemy y axis divided by 64

What it does (pseudo, just the main stuff):
Code: [Select]
X set to 3104 (48.5 when divided by 64)
Y set to 2080 (32.5 when divided by 64)
Game loop:
Change Xdt to Xd
Change Ydt to Yd
Check if 1 pixel above the player is solid
-if so, multiply VY by -1
Check if player can move down
-if not, set VY (VY is the velocity of Y axis) to 0
-if it can move down, subtract 8 from VY
Check if left button pressed
-if so, check pixels and if it can go left, subtract 64 to Xd
-If it cannot move left, check if to the left and above 1 pixel is clear, and if so, subtract 64 from Xd and add 64 to Yd and Ym, so it moves diagonal
(Same with going right, except it adds 64 to Xd, not subtracts)
Checks if center button pressed
-If so, check if 1 pixel above the player is clear, and if so, change VY to 64

Add VY to Yd
Change xt to Xdt - Xd
Change yt to VY + Ym and then multiply it by -1
Change xtt to Xd/-64
Change ytt to Yd/64

Add xt to ex
Add yt to ey
Move enemy and such
Change ex64 to ex/64
Change ey64 to ey/64

Draw all the stuff. Draws the enemy by using ex64 and ey64
End game loop;

EDIT: Sorry it took so long. :P
« Last Edit: March 15, 2012, 04:03:44 pm by nxtboy III »

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Some limitations of platformers using pxl-test
« Reply #37 on: March 15, 2012, 04:05:51 pm »
That looks a bit more complicated than needed, but did you also remember to set the enemies on half pixels?

Offline nxtboy III

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 795
  • Rating: +26/-1
  • NXT!
    • View Profile
    • Program NXT
Re: Some limitations of platformers using pxl-test
« Reply #38 on: March 15, 2012, 04:07:24 pm »
Oh, forget to tell you. Yeah I set the enemy on 4128 (64.5) for the X and 2080 (32.5) on the Y.

Also, if you could help get it less complicated, that would be great.
« Last Edit: March 15, 2012, 04:07:52 pm by nxtboy III »

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Some limitations of platformers using pxl-test
« Reply #39 on: March 15, 2012, 04:21:55 pm »
Okay, here is one way to do it:
Code: [Select]
X=3104       ;sets X-coordinate to 3104
Y=2080       ;Sets Y-coordinate to 2080
XE=4128      ;Sets Enemy X coordinate
YE=2080      ;Sets Enemy Y coordinate
Vy=0         ;Zero out the y velocity

// Now you are ready to do the gravity stuff!
// First we update the velocity:
Vy =Vy+4     ;Increments the Y velocity by 4

//Now we update position
YE =YE-Vy    ;Subtracts the new velocity from the position of the enemy
Y  =Y+Vy     ;Adds the new velocity to the position of you

//Now you divide the positions by 64 and use those as the coordinates :)
I am not sure how to do that on the NXT


Also, here is a very simple hitbox example that I made :)

Offline nxtboy III

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 795
  • Rating: +26/-1
  • NXT!
    • View Profile
    • Program NXT
Re: Some limitations of platformers using pxl-test
« Reply #40 on: March 15, 2012, 04:39:34 pm »
Why increment velocity by 4?
Lemme try...

EDIT: Still, it doesn't work!!! Why??  :'(
« Last Edit: March 15, 2012, 04:43:07 pm by nxtboy III »

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Some limitations of platformers using pxl-test
« Reply #41 on: March 15, 2012, 04:48:16 pm »
Oh, I was incrementing the velocity by a number (doesn't have to be 4) to simulate a gravity-like effect. v=at, but t is measuerd in cycles, so you just add "a" every time. In this case, 4.

Offline nxtboy III

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 795
  • Rating: +26/-1
  • NXT!
    • View Profile
    • Program NXT
Re: Some limitations of platformers using pxl-test
« Reply #42 on: March 15, 2012, 04:55:26 pm »
I can show you a screenie. It looks really bad because I am viewing the screen on the computer. (Doesn't look bad on NXT)
The number on the bottom left corner is the Y axis of the map minus the y axis of one of the enemies(The enemies are the squares). When the enemy is not moving it should stay the same. It should stay at -9. But it does not.
Sorry it's an .avi and it is so flickery (It is because of the screen capture program). Hopefully you are not epileptic. :P
I had to zip it up because of the size.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Some limitations of platformers using pxl-test
« Reply #43 on: March 15, 2012, 05:14:37 pm »
I have looked at it and it really does look quite nice, by the way. I see what you mean and I plan to see if I can come up with some working code. The enemies just follow you, but they cannot jump, right?

Also, I won't be back until 4 hours from now (supper, then work).

Offline nxtboy III

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 795
  • Rating: +26/-1
  • NXT!
    • View Profile
    • Program NXT
Re: Some limitations of platformers using pxl-test
« Reply #44 on: March 15, 2012, 05:23:59 pm »
Yeah, they just follow, not jump.

On my NXT, the grayscale doesn't look to bad at all. :)

Thanks for the help. :)
Yeah, hopefully this can get working soon.

EDIT: So does anybody else know of any limitations and/or solutions for pixel-perfect collision platformers?
« Last Edit: March 15, 2012, 05:42:30 pm by nxtboy III »