gfxgfx
 
Please login or register.

Login with username, password and session length
 
gfx gfx
gfxgfx
 
Members, please note that our guidelines are located here.
 
gfx gfx
gfx
484586 Posts in 28410 Topics by 2464 Members - Latest Member: austinrobert July 11, 2020, 06:32:40 PM
*
gfx* Home | Help | Calendar | Login | Register | gfx
gfx
The Gaming Universe  |  The Archives  |  Archived Projects  |  Open Zelda  |  OZ Help (Moderator: red_team316)  |  Making a Puzzle
gfx
gfxgfx
 

Author Topic: Making a Puzzle  (Read 1420 times)

Offline Khatuni

  • Executive
  • ***
  • Posts: 1,007
    • View Profile
Making a Puzzle
« on: September 26, 2010, 09:04:43 AM »
I'm making a 120 piece jigsaw puzzle in OZ and I was like "Oh crap, that means I have to make 120 sprites out of 1 image all one by one ("piece000" -- "piece119").".

Wouldn't it be useful to have a function that can draw a part of a sprite instead of the whole sprite? That way I could just make 1 sprite out of the entire image, and it would take only a few script lines to draw the 120 pieces.

Offline KingOfHumans

  • Messiah
  • ******
  • Posts: 17,866
    • View Profile
Making a Puzzle
« Reply #1 on: September 26, 2010, 11:27:08 AM »
Unless if your making a square jigsaw, I'm not sure how it would be done.

Offline Khatuni

  • Executive
  • ***
  • Posts: 1,007
    • View Profile
Making a Puzzle
« Reply #2 on: September 26, 2010, 01:26:19 PM »
The pieces are 24x20 px rectangles. Not with the flaps and gaps of classic jigsaw pieces, of course.

Offline Luke

  • Regimental
  • ****
  • Posts: 1,823
    • View Profile
Making a Puzzle
« Reply #3 on: September 26, 2010, 07:30:42 PM »
I'm making a 120 piece jigsaw puzzle in OZ and I was like "Oh crap, that means I have to make 120 sprites out of 1 image all one by one ("piece000" -- "piece119").".

Wouldn't it be useful to have a function that can draw a part of a sprite instead of the whole sprite? That way I could just make 1 sprite out of the entire image, and it would take only a few script lines to draw the 120 pieces.
Why not just create a script in your favorite language to create the sheet info? If you look around the forum you will find the format of the spritesheet, when it just a simple two loops.

Code: [Select]
/* Code from Open Legends' Quick Create. which does what you want done automatically */
/*   you will most likely not get this :)     */
for (; yc < section_height; yc += height )
{
xc = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(spin_left) );
for (; xc < section_width; xc += width )
{
g_string_append_printf( content, "%d\t0\t0\t0\t%d\t%d\t%d\t%d\n", ++c, xc, yc, width, height);
}
}

Offline Khatuni

  • Executive
  • ***
  • Posts: 1,007
    • View Profile
Making a Puzzle
« Reply #4 on: September 27, 2010, 06:17:33 AM »
A script in my favorite language?...  Small is the only language used in OZ6.5. If you're talking about editing the OZ source, then that's out of the question since 6.5's source cannot be found anywhere.

Offline Luke

  • Regimental
  • ****
  • Posts: 1,823
    • View Profile
Making a Puzzle
« Reply #5 on: September 27, 2010, 07:54:20 AM »
Sprite sheets info are stored in a text file, you can use a scripting language, such as javascript, PHP or even Small, to create that info.

The code I posted is how Open Legends can create 120 24x20px sprites automatically, you would need to change the 'g_string_append_printf' line to match the language and the output you need.


This is something KoH could easily help you out with.

Offline Khatuni

  • Executive
  • ***
  • Posts: 1,007
    • View Profile
Making a Puzzle
« Reply #6 on: September 27, 2010, 08:32:56 AM »
Well I'm really interested in that. I usually never edit .spt files since it's not much faster than editing a sheet in the QD, but I never knew it was possible to write a function for them. Thanks for the info.

Offline KingOfHumans

  • Messiah
  • ******
  • Posts: 17,866
    • View Profile
Making a Puzzle
« Reply #7 on: September 27, 2010, 06:12:30 PM »
You could create a screen script and either use TextFile/ToFile or printf. Then copy that data and copy it to the .spt file.
It should be so simple that you can easily make it.

Offline Khatuni

  • Executive
  • ***
  • Posts: 1,007
    • View Profile
Making a Puzzle
« Reply #8 on: September 28, 2010, 05:42:38 PM »
Hmm I never used those functions before, but this is exactly what I need.
I just need to know how to skip a line in the log file. It's probably a certain character but I can't find it...

Oh, and is it possible to somehow write directly into an .spt file? That way I could change the sprite's names and coordinates during play. (imagine the possibilities  :p)

Offline KingOfHumans

  • Messiah
  • ******
  • Posts: 17,866
    • View Profile
Making a Puzzle
« Reply #9 on: September 28, 2010, 10:11:50 PM »
TextFile(""); < Maybe this.

Just open the spt file in notepad and paste.
There's no way to read a file or change a file.

Offline Khatuni

  • Executive
  • ***
  • Posts: 1,007
    • View Profile
Making a Puzzle
« Reply #10 on: September 29, 2010, 07:02:21 AM »
Actually I meant going to the next line, instead of leaving one empty. But TextFile does the trick; printf writes everything on 1 line.

Offline KingOfHumans

  • Messiah
  • ******
  • Posts: 17,866
    • View Profile
Making a Puzzle
« Reply #11 on: September 29, 2010, 08:21:50 AM »
Use ^n or maybe it's /n for printf

The Gaming Universe  |  The Archives  |  Archived Projects  |  Open Zelda  |  OZ Help (Moderator: red_team316)  |  Making a Puzzle
 

gfxgfx
gfx
SMF 2.0.17 | SMF © 2019, Simple Machines Page created in 0.149 seconds with 21 queries.
Helios Multi © Bloc
gfx
Powered by MySQL Powered by PHP Valid XHTML 1.0! Valid CSS!
anything