Join us on Discord!
You can help CodeWalrus stay online by donating here.

[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 1 Guest are viewing this topic.

Dream of Omnimaga

Glad to see progress JWinslow23. Also I like that color scheme better. :)
  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

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

Dream of Omnimaga

Oh, I thought it was fixed. I guess I got too used at the grayscale version :P
  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U


Dream of Omnimaga

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

  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

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

#22
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.

Dream of Omnimaga

  • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
  • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

JWinslow23

#24
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.

Yuki

  • Calculators owned: TI-83+ (dead?), Casio Prizm (also dead???)
  • Consoles, mobile devices and vintage computers owned: A lot
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