Alternatively, join us on Discord.

+-Recent Topics

[TI-84+CE] This Is The Only Level +CE

Started by JWinslow23, September 11, 2016, 10:13:25 pm

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

DJ Omnimaga

Glad to see progress JWinslow23. Also I like that color scheme better. :)

MateoConLechuga

Quote from: DJ Omnimaga on September 12, 2016, 11:44:28 pm
Glad to see progress JWinslow23. Also I like that color scheme better. :)

I believe the color scheme is randomly generated each time :)

DJ Omnimaga

Oh, I thought it was fixed. I guess I got too used at the grayscale version :P


DJ Omnimaga

Lol that's because I am still quite into calc games. :P


JWinslow23

I'm having a small problem with jumping. When the elephant hits the ground, his y-position (a float) needs to be a multiple of 11 plus a constant offset. I know how to check for when he hits the ground, but how, in code, would I make sure his y-position is a multiple of 11 plus a constant offset?

The y-position is a double with name player_y, and the constant offset is a defined integer with name TILEMAP_Y_OFFSET.

MateoConLechuga


JWinslow23

September 14, 2016, 12:35:47 am #22 Last Edit: September 14, 2016, 01:07:34 am by JWinslow23
Not working. Apparently you can't do a modulus operator to a double.

EDIT: Also, the Y-position being a double is causing problems elsewhere. I think I need help with datatypes.

The Y-velocity needs to be a double, but I'm not sure about the Y-position.

EDIT AGAIN: Code is attached.


I am freaking stupid.

DJ Omnimaga


JWinslow23

September 14, 2016, 05:44:22 am #24 Last Edit: September 14, 2016, 06:10:59 am by JWinslow23
Quote from: DJ Omnimaga on September 14, 2016, 05:33:07 am
How is the speed so far?

Very playable. The screenshot is slow for some reason, I blame Cemu.



Also, new version!

It adds jumping, gravity, a little bounce mechanic, and death! It also adds a placeholder for where a timer will be, if I can figure out how to time to the 100th of a second.

Download attached.

Juju

Read Zarmina!
YUKI-CHAAAANNNN
In the beginning there was walrii. In the end there will be walrii. All hail our supreme leader :walrii: --Snektron



if you wanna throw money at me and/or CodeWalrus monthly it's here

MateoConLechuga

Here's an optimized version of hit_block: (I also changed the inputs to uint8_t)

bool hit_block( uint8_t hit_x, uint8_t hit_y, uint8_t block_hit ) {
uint8_t x_off1 = (hit_x - TILEMAP_X_OFFSET) / TILE_WIDTH;
uint8_t x_off2 = (hit_x + TILE_WIDTH  - TILEMAP_X_OFFSET - 1) / TILE_WIDTH;
uint8_t y_off1 = (hit_y - TILEMAP_Y_OFFSET) / TILE_HEIGHT;
uint8_t y_off2 = (hit_y + TILE_HEIGHT - TILEMAP_Y_OFFSET - 1) / TILE_HEIGHT;

return (collision( x_off1, y_off1 ) == block_hit) ||
(collision( x_off1, y_off2 ) == block_hit) ||
(collision( x_off2, y_off1 ) == block_hit) ||
(collision( x_off2, y_off2 ) == block_hit) ;
}


Notice that in code; if you have loops and stuff, it repeats that code every single time. Better to just store the computations and then use them I guess.

JWinslow23

Quote from: MateoConLechuga on September 14, 2016, 06:46:06 am
Here's an optimized version of hit_block: (I also changed the inputs to uint8_t)

bool hit_block( uint8_t hit_x, uint8_t hit_y, uint8_t block_hit ) {
uint8_t x_off1 = (hit_x - TILEMAP_X_OFFSET) / TILE_WIDTH;
uint8_t x_off2 = (hit_x + TILE_WIDTH  - TILEMAP_X_OFFSET - 1) / TILE_WIDTH;
uint8_t y_off1 = (hit_y - TILEMAP_Y_OFFSET) / TILE_HEIGHT;
uint8_t y_off2 = (hit_y + TILE_HEIGHT - TILEMAP_Y_OFFSET - 1) / TILE_HEIGHT;

return (collision( x_off1, y_off1 ) == block_hit) ||
(collision( x_off1, y_off2 ) == block_hit) ||
(collision( x_off2, y_off1 ) == block_hit) ||
(collision( x_off2, y_off2 ) == block_hit) ;
}


Notice that in code; if you have loops and stuff, it repeats that code every single time. Better to just store the computations and then use them I guess.

Do you think that the inputs ought to be uint8_t's? Those are the literal coordinates of the guy on-screen, which doesn't take those.

MateoConLechuga

Haha, oops, yeah. Well, the y value can be, but the x value should be a uint24_t :P The rest is fine.


Powered by EzPortal