Hey everyone! I've been working on my CC24 entry, and I need some help with tilemaps. I get how to create them and export them as a .csv, but I need help converting them to an appvar I can use from my program. Is this possible, and if so, how do I do it?
(I'm on macOS 10.15.7 and have CrossOver, if that helps)
https://github.com/PeterTillema/ICE/wiki/Creating-tilemaps

https://github.com/PeterTillema/ICE/wiki/Loading-tilemaps

https://github.com/PeterTillema/ICE/wiki/Displaying-tilemaps

https://github.com/PeterTillema/ICE/wiki/Changing-tilemaps
Thank you!
I have another question, I'm on macOS and can't use convbin to convert .csv files. Is there a mac version that I don't know about? Or am I doing something incorrect?

Thanks,
KMisthebomb
Just download it and build it.
thanks for the help! it worked!
This isn't really about creating tilemaps, but how would you detect if a player is on a tile?
So in the CEdev examples/gfx folder, there's an example called "tilemaps" (which I know isn't ICE but it makes for a good example). In it are 2 variables:

Code:
unsigned int x_offset = 0;
unsigned int y_offset = 0;

They keep track of where to draw the tilemap, and measure from the pixel coordinates (0,0) on the display. You can just add the X 'n Y positions of your avatar to that and then divide by the width of each tilemap image, so something simple like this can calculate them:

Code:
playerTileX = (x_offset + playerX) / TILE_WIDTH;
playerTileY = (y_offset + playerY) / TILE_HEIGHT;

Note that the x_offset goes up when moving right and down when moving left, with the same rules applying to the y_offset, like moving to coordinates on the graph screen (which is weird to explain, it makes more sense if you see the code run). Also, you have to keep in mind that this measures where the player X+Y coords are, not where the player sprite appears to be. How you handle that depends on how you handle player movement. Just use something to check the tiles around your avatar and see if they're the one you're trying to touch/not touch.
Whoa, that's cool! Thanks for the help, King Dub Dub!
KMisthebomb wrote:
thanks for the help! it worked!

Ok, I kind of lied. Unsure
What I meant was I got convbin to output ice.txt.
But I need help on how to use convimg, 'cause I'm very confused. My current convimg.yaml looks like:

Code:

output: ice
  include-file: ice.txt
  palettes:
    - xlibc
  converts:
    - myimages

palette:
  name: mypalette
  images: automatic

convert: map
  palette: xlibc
  tilesets:
    tile-width: 32
    tile-height: 32
    images:
      - tileset.png

But I need some help on what to type where it has 'mypalette' and 'myimgages', and if my file is correct.
Can someone help me please?
All righty, so the first thing you'll want to do is grab the latest convimg from here: https://github.com/mateoconlechuga/convimg/releases/latest

PT_ hasn't told me what the output for tilemaps should look like, so you have to store the tileset into an AppVar and use it from there. I'm sure there's some guide out there on this, but who knows.

Anyway, the convimg.yaml you would use to create this tileset appvar is shown below:


Code:
palettes:
  - name: global_palette
    images: automatic
    fixed-entries:
      - color: {index: 0, r: 255, g: 255, b: 255}
      - color: {index: 1, r: 0, g: 0, b: 0  }

converts:
  - name: tileset
    palette: global_palette
    tilesets:
      tile-width: 32
      tile-height: 32
      images:
        - tileset.png

outputs:
  - type: appvar
    source-format: ice
    name: tileset
    header-string: MY_AWESOME_TILESET
    palettes:
      - global_palette
    converts:
      - tileset


When you run convimg on this file, you will get a tileset.8xv appvar. Note that it uses a custom palette; if you prefer to use the xlibc palette feel free; just remove the respective references in convimg.yaml. If you use the xlibc palette, the palette will not be stored in the appvar.

As for the location in the appvar where the images and palettes are; right now ICE format just places them in the order that they are defined. First, the header string "MY_AWESOME_TILESET" is found, followed directly by any palettes. Sprites are then found directly after the palettes. Each tile is a sprite that is (tile-width * tile-height + 2) bytes in size, and the tile sprite is mapped to the tileset by working from the top left to the bottom right of the input image.

Since the palette may be variable size, I might recommend using the convimg command prepend-palette-sizes so you can know the sizes of the palette from the appvar, or use the undocumented command output-first: converts in the appvar section to output the tiles first instead of the palette in the appvar. The first one is probably easier.

Let me know if you need any more help Smile
I got convimg to output the appvar, but can't figure out how to use DefineTilemap. Right now my code looks like:

Code:

[i]A
LoadData("MAP",0,400)->A
DefineTilemap(32,32,20,20,5,5,0,0,A)->MAP
det(0)
Tilemap(MAP,0,0
Pause
det(1)

I feel like this is correct, but I'm not sure. Any suggestions?
Sorry if there was an answer somewhere. I tried to find one but failed in doing so Sad .

EDIT: I got DefineTilemap to work (kind of), but when I ran the program, it displayed random pixels that were 32x32 and then crashed Shock
I've never used ICE so idk Razz
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are GMT - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement