Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.
I am making my first game programmed in ICE. I don't have any experience in programming except in TI-BASIC and after exploring Cemetech for a while and then finding the ICE Compiler in the Archives I decided to learn ICE and program my first game, SpherixCE.

Following the amazingly explained "Documentation ICE v2.2.1" while also looking at the "ICE Compiler Commands List", I have been off to a good start. I found a good tileset off the internet and selected 16 different tiles which I made into a new tileset (the original tileset had over 900 tiles!). After running into a few problems (including changing the name of windows - convtile and windows - conpng to convtile and convpng respectively and not knowing what command prompt was), I got stuck on the following instructions:



Open Command Prompt Did
Navigate to the folder Did

Run convtile --ice
I ran convtile through Command Prompt which didn't seem to work:



I renamed convtile to convtile --ice and ran through command prompt and that didn't work either. I tried putting my .csv file onto convtile to see if it would work that way and it didn't. I searched "convtile" through Cemetech's search engine and I realize there's already a forum for convtile, but since I was told in the SAX to post about my program, I've decided just to make my own forum


The Tileset!:
I believe convtile is for converting a tilemap exported from Tiled, which is available at https://www.mapeditor.org/

If you want to convert a tileset (the graphics) then you will need to check out convpng - which I believe is mentioned in the guide you are following? http://learn.cemetech.net/index.php/ICE:Using_ICE#Tilemaps
convtile doesn't exist anymore. There's only convcsv, which you can find here: https://github.com/mateoconlechuga/convcsv/releases/latest

You have a tileset, which is the sprites for a tilemap. To convert a tileset, follow the guide using convpng.
To convert a tilemap using convcsv (rather than convtile), use the following syntax, where tilemap.csv contains the tilemap created with Tiled or similar.


Code:
convcsv -i tilemap.csv tilemap.txt


tilemap.txt will now contain the array you can use in your ICE program.
MateoConLechuga wrote:

To convert a tileset, follow the guide using convpng.


I went ahead and already did that step

MateoConLechuga wrote:

To convert a tilemap using convcsv (rather than convtile), use the following syntax, where tilemap.csv contains the tilemap created with Tiled or similar.


Code:
convcsv -i tilemap.csv tilemap.txt


tilemap.txt will now contain the array you can use in your ICE program.






I'm still not sure why this isn't working. What is "code 1"?
code 1 means that it cannot figure out what file you are trying to convert. You can't just run the application like that. You need to use the cd command to navigate to the directory that contains both convcsv and the file you are trying to convert, and then you can run the executable with just convcsv.exe -i Level1.csv tilemap.txt

When we say what to put into a command terminal, it should be **exactly** what we say. Not extra paths, not missing things, etc.
Thank for bearing with my stupidity MateoC. I got the tilemap displayed correctly on my calculator and I will start on game mechanics. I am planning on making a pseudomatrix of the tilemap (technically a list since ICE does not directly have a matrix feature) and sort of like the .csv file containing my tiles, create a list containing the dimensions of the tilemap along with number corresponding to different tiles. Of course, the chest can contain more than one thing, so that alone will take a couple different values up. When you move Spherix (the blue sphere) the program will find Spherix's code number in the list and move it accordingly in the list, replacing the tile it was last on with a blank tile (checking for walls, items, etc. of course). The map should only have to redraw the tile spherix was on and the tile spherix is currently on.

And now that I have a little progress, I should explain what the game is about. SpherixCE is supposed to be a puzzle game where your goal is to get to the rainbow "door" to advance to the next level. I plan to add more tiles later, but for now this is what each tile does:

This is spherix. You navigate him through each level

This is, well, the floor... you can walk on it

This is a wall, and unlike the floor, you can't walk on it

Water, can be "neutralized" by Red Crystal

Lava, can be "neutralized" by Blue Crystal

White Crystal, "neutralizes" black hole

Red Crystal, "neutralizes" water

Blue Crystal "neutralizes" lava

Green Crystal, needed to go through rainbow door

Used to open chest

Can contain a crystal or another key


These are bridges. You can safely walk over water now (ironically, Spherix is 93% water, in frozen form of course)

A Boulder. Sometimes these are in the way and need to be pushed around to get to where you need to go (they're sort of like younger siblings)

The "Rainbow" Door. The exit to each level. The green crystal needed before entering

It's a black hole. Stepping in one without a white crystal is most likely fatal.


Here's Level 1:
irc wrote:
18:05 <MateoC> Kaluwolf++
18:05 <saxjax> [Kaluwolf] yeah
18:06 <MateoC> very nice work Smile
18:07 <MateoC> looks like it's coming together
MateoC told me you can store a sprite into an appvar instead of having an obnoxious program with a definesprite() command followed by a couple thousand characters. For the Write() command, the syntax is sum(4,"DATA",SIZE,COUNT,SLOT). I assume "DATA" would just be the pointer to the sprite, but how big would SIZE be? My sprite is 32x32 pixels (the data for the sprite is 2,048 characters long - 32*32*2). How large would my SIZE be? Or am I doing this totally wrong?
You can use convpng to store the sprite to an appvar:

https://github.com/mateoconlechuga/convpng/blob/master/examples/c_appvar/convpng.ini

Example is for C but just change C to ICE and it will work.

Then you can just use GetDataPtr to get a pointer to the sprite in the appvar memory.
MateoConLechuga wrote:
You can use convpng to store the sprite to an appvar:

https://github.com/mateoconlechuga/convpng/blob/master/examples/c_appvar/convpng.ini

Example is for C but just change C to ICE and it will work.

Then you can just use GetDataPtr to get a pointer to the sprite in the appvar memory.



Code:
#AppvarC           : var_gfx
#IncludePalettes   : all_gfx
#PNGImages         :
 sprite_2
 sprite_1

#GroupC            : all_gfx
#PaletteMaxSize    : 14
#PNGImages         :
 sprite_1
 sprite_2


Why are there two sprites? I assume it will work with only one?
It's an example with 2 sprites Razz Use 1 sprite if you don't have two sprites that you want to put in an appvar.
Alright, update time. I got each level (tilemap) to render one after another (after taking a peek at PT_'s The World's Hardest Game) I got everything stored safely away into appvars. The problem is, I want more tiles in the game (pressure plates for the boulders, bridges are pretty stupid, levers). This wouldn't be a problem except.... I'm a terrible artist, like 5 year olds can draw better than me. I was wondering if anyone wanted to help me make more sprites (that don't look horrible and flow with the rest of the tilemap). Thanks in advance!
Can't you just like "borrow" some from somewhere on the internet?
MateoConLechuga wrote:
Can't you just like "borrow" some from somewhere on the internet?


I guess so. (*sighs*) That's what I did with the original tileset, except it took me well over an hour to find.
Kaluwolf wrote:
Alright, update time. I got each level (tilemap) to render one after another (after taking a peek at PT_'s The World's Hardest Game) I got everything stored safely away into appvars. The problem is, I want more tiles in the game (pressure plates for the boulders, bridges are pretty stupid, levers). This wouldn't be a problem except.... I'm a terrible artist, like 5 year olds can draw better than me. I was wondering if anyone wanted to help me make more sprites (that don't look horrible and flow with the rest of the tilemap). Thanks in advance!

I wouldn't mind drawing a few sprites for you.
I've got some examples of sprites I drew here, here, and here.
In my program I'm rebuilding the list containing the tilemap code each time I move spherix. When I ran my code, it wasn't working properly, so I conducted a small test:


Code:
[i]A
"A->D
Copy(Str1,D,1
Disp Str1
Pause


When I run this it displays an "A" followed by a sub scripted "2" followed by some weird box. Could someone explain this to me please?
Kaluwolf wrote:
In my program I'm rebuilding the list containing the tilemap code each time I move spherix. When I ran my code, it wasn't working properly, so I conducted a small test:


Code:
[i]A
"A"→D
Copy(Str1,D,1
Disp Str1
Pause


When I run this it displays an "A" followed by a sub scripted "2" followed by some weird box. Could someone explain this to me please?

Every string has a terminating zero after it, so the string "A" actually is read by the system as {'A', 0}.
Therefore, when using the Copy( command, you must add 1 to the length of the string so that the terminating zero gets copied as well. Otherwise, when you try to display it, it will just continue to display junk until it reaches a terminating zero.
your code can simply be fixed like this:

Code:
[i]A
"A"→D
Copy(Str1,D,2 //copy length(D)+1 bytes of string D into Str1
Disp Str1
Pause

I hope this helps Smile
Thanks a lot!
My question is then:


Code:
[i]A
"PINEAPPLE->A
Copy(Str1,A,9
Disp Str1
Pause


This works however... how does that work?

Oh... and PT_ should probably add that information in his documentation Very Happy
It could be REAAAALLY useful. Cool Cool
It has been less than 24 hours, but I will double-post. Yesterday and today I implemented game mechanics, namely, moving Spherix around. So basically this how I wanted this to work: There is data for the tilemap in hex found in tilemap.txt. My idea is that every time I move Spherix, I rewrite the data for tilemap. How do I do this? I create the string (Str1) containing the original data for the tilemap from tilemap.txt. Each time I move Spherix, it first checks for any obstacles (using the compare() syntax to check the tile code Spherix is trying to move to). If Spherix is not trying to phase through walls or levitate over holes, the program will "rebuild" the string that contains the data for the tilemap, moving the Spherix tile (hex code 00) in the data for the tilemap, accordingly (along with boulders, crystals, etc.). It then stores the String back into the appvar that contains the data for the tilemap. The program loops back to Lbl MOVE where it gets the data pointer GetDataPtr() for the tilemap and displays it. My problem is, that... well, it doesn't work. When I try to move Spherix I get greeted by the "RAM Reset" Screen. Here is my code.

I tried to explain it as best as I could:

Code:

//Hex codes for each tile; Used during the Compare() syntax
//00 - Spherx
//01 - Floor
//02 - Hole ***
//03 - Wall
//04 - Boulder
//05 - Sticky Plate ***
//06 - Key ***
//07 - Chest ***
//08 - White Crystal ***
//09 - Green Crystal (Switch) ***
//0A - Blue Crystal ***
//0B - Red Crystal (Switch) ***
//0C - Rainbow Door ***
//
//*** Not implemented yet
//
//
[i]SPHERIX

CloseAll
Open("SpherixL","r")->LEVELS
If not(LEVELS
   ClrHome
   Disp "AppVar SpherixL Missing"
   Pause
   Return
End
Open("SpherixT","r")->TILES
If not(TILES
   Disp "AppVar SpherixT Missing"
   Pause
   Return
End

//This is the Data for the tilemap from SpherixL
"030303030303030303030303030001030101030602010103030101040101030202010103030303030101010101010103030101010101070101010103030101010101010101010103030108010101010101010103030101010101010101010103030303030303030303030C03"->Str1

LoadData("SpherixT",0,39->A
DefineTilemap(32,32,9,12,5,5,9,12,0,0,A->TILEMAP

Begin
//Seek(108,1,LEVELS    -- Don't need this yet; This for multiple levels
SetTextScale(1,2
PrintStringXY("SpherixCE",1,1

//Sets up some variables: CRYW = Crystal White; CRYB = Crystal Blue; And POS is the position where Spherix is located on a 12x9 tilemap. Since the first tile is 0, Spherix's location would be down one row and two columns over
0->CRYW->CRYB->KEYS+13->POS

//Acts as a loop. No way to get out of it, but right now, all that happens are RAM resets when I try to move
Lbl MOVE

//Displays the tilemap
GetDataPtr(LEVELS->{TILEMAP}
Tilemap(TILEMAP,0,16
Repeat (KEY>0 and KEY<5)
   getKey->KEY
End

//TPOS is the position where Spherix is going to move, and BPOS is where a potential boulder would move
POS-(KEY=2 and remainder(POS,12)!=2)+(KEY=3 and remainder(POS,12)!=9)-12*(KEY=4 and POS>24)+12*(KEY=1 and POS<83)->TPOS-(KEY=2 and remainder(POS,12)!=2)+(KEY=3 and remainder(POS,12)!=9)-12*(KEY=4 and POS>24)+12*(KEY=1 and POS<83)->BPOS
sub(Str1,2*TPOS,2)->Str2

//This next section figues out what the tile Spherix is moving to contains
If (compare(Str2,"02")=0 and CRYW=0) or compare(Str2,"03")=0 or (compare(Str2,"0C")=0 and CRYB=0)
   Goto MOVE
End
If compare(Str2,"06")=0
   KEYS+1->KEYS
End
If compare(Str2,"08")=0
   CRYW+1->CRYW
End
If compare(Str2,"0A")=0
   1->CRYB
End

//This rebuilds the data for the tilemap, with the new position of the boulder; replacing the old position of the boulder with the floor tile
If compare(Str2,"04")=0
   sub(Str1,2*BPOS,2)->Str3
   If compare(Str3,"01")!=0
      Goto MOVE
   End
   "03->Str0
   For(REBUILD,1,107
      sub(Str1,2*REBUILD,2->Str9
      If REBUILD=BPOS
         "04->Str9
      End
      If REBUILD=TPOS
         "01->Str9
      End
      Str0+Str9->Str0
   End
End

//This rebuilds the data for the tilemap, with the new position of Spherix; replacing the old position of Spherix with the floor tile
"03->Str0
For(REBUILD,1,107
   sub(Str1,2*REBUILD,2->Str9
   If REBUILD=TPOS
      "00->Str9
   End
   If REBUILD=POS
      "01->Str9
   End
   Str0+Str9->Str0
End

// The rebuilt tilemap data replaces the old tilemap data
Str0->Str1

//Stores the Data back to the appvar SpherixL to be recalled again through GetDataPtr()
Open("SpherixL","r+"->LEVELS
Copy(DATA,Str1,109  //One extra byte for the terminating zero or whatever
Write(DATA,108,1,LEVELS
Goto MOVE
det(1


I think it is resetting during in the last part of my code (Open() to Write()) but I'm not sure. If someone could identify the problem (or potentially problems), that would be great.
Use the Tilemap function please. It has the offsets there for a reason.
You then render sprites on top of the tilemap.
Alternatively you should read the tilemap from the appvar, store it in ram, and then use the TilePtrMapped (or TilePtr) function (Which you should already be using for collisions!!).
  
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 2
» 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