The Daily Click ::. Forums ::. Klik Coding Help ::. Load external images - help needed
 

Post Reply  Post Oekaki 
 

Posted By Message

Toni Montano



Registered
  13/10/2012 05:35:39
Points
  15
17th October, 2013 at 17/10/2013 19:38:50 -

Hi guys,

I created several images which i will use as race tracks in my racing game. There is around 100 race tracks (approx. size 3500x2000)which i must load into game externally. What would be the best way to load them into the game? Using INI files or something else?

And also, i would like to use tiles in background of race track images that I can make different conditions of surface. Which metod would be the most suitable?

Thx for answers

 
n/a

Chloe Sagal

under the influence of FUN

Registered
  19/02/2009
Points
  607

Orange
18th October, 2013 at 18/10/2013 09:18:48 -

Oh gee. I've been doing this for the last few days.

There are several options you have at your disposal,

Load Frame: A function on active objects, should work just fine for what you need.
Active Picture: As long as the picture doesn't need to animate, you'll be fine with this. I use these for my level editors, as it allows you to paste a section of the loaded picture into the backdrop.
Text Blitter: It works, though, meh. I've had bad experiences with Text Blitter.
Animated Picture: It'll load in your backgrounds, and animate them as well.

So depending on what you choose, now you just need to come up with a way to load them in. First off, figure out your condition for loading the picture, e.g. start of frame, click on a button, pick an option from a list, whatever.

I'm going to assume that your tracks are all going to be named the same way. e.g. track000, track001, track002, track003, etc. To load that, all you'll need to do is go to the load function of your choosing (Load Frame, Active Picture, etc.) And if the file selection pops up, hit 'calculation' or 'expression' so the expression editor pops up. In there you'll start with the code AppPath$, or AppDrive$+AppDir$, or if you're on iOS leave that out. Then follow it by
+"[name of the folder your tracks are in]\"+Str$(Random(100))+".png"

Now, the section says [name of the folder...], you can always set that to an alterable string as well. I find that useful for any folders that I reference, in case I need to reference it several times, that way, if I end up finding that the name of the folder needs to change, I only need to change the alterable string that is being referenced, rather than having to dig through all my code to find every single place that I've posted it.
So in full it's

AppPath$+"Folder\"+Str$(Random(100))+".png" or
AppDrive$+AppDir$+folderString("randomDataHoldingObject")+"\"+Str$(Random(100))+".png"

Now, if all of your tracks aren't named as such, then you'd have to create an ini file. You can just create a .txt file, then create two groups, [properties] and [tracks]. In the properties group, create an item called trackCount, and set it to the amount of tracks in your folder. In the tracks group, start from 0, and go to 100, and set them equal to the name of all your tracks. So in other words:

[properties]
trackCount=100

[tracks]
0=derpyTrack.png
1=lameNameConvention.bmp
2=thisCanGetTedious.jpg
3=mightBeEasierToCreateAnAutomationSystemThatExportsTheContentsOfAListThatReadsTheContentsOfMyFolderToAnIni.wav
...

Then, to load a map, same as the other option, except in that little spot where you said Str$(Random(100)), replace it with:

GroupItemString$( "ini", "tracks", Str$(Random(Val(GroupItemString$( "ini", "properties", "trackCount")))))

That might seem like a waste of time, but it has some pretty gnarly applications that has worked very well for me thusfar.

But, that should get you started on question one. The second question... I'm not exactly sure what you're asking. Are you asking about how to make a level editor where you can build your levels from a tileset?

 
Patreon: http://www.patreon.com/chloesagal
Twitter: https://twitter.com/ChloeSagal

Toni Montano



Registered
  13/10/2012 05:35:39
Points
  15
18th October, 2013 at 18/10/2013 09:43:04 -

Thx for the answer "Chloe Sagal", I will try it now what you said.

Second question: I allready made level editor with my palete of tiles. Then i create several paths with tiles and save it in ini file (with active object). In ini file is: Object No. counter, Object Type, Object x and y position and object layer. I load them into my game frame and I use "add backdrop" (because it doesn't affect much on memory) that i can see tiles on my backdrop image. Now i want to give a condition to this tiles, for example:

- Let say that I have 2 tiles, first is red square and second is green one.
- Condition for red tile would be: when "my player" overlap red tile - set "max_speed to 10"
- Condition for green would be similar except that i would like to set "max_speed to 8"

Here I'm having a problem, when i give: "my player" is overlaping a backdrop - I have all tiles as one backdrop and can't give them different conditions. Is it possible that i can seperate my tiles even they are backdrops or must I use "Create object" command?

Thx again for the answer

 
n/a

Toni Montano



Registered
  13/10/2012 05:35:39
Points
  15
18th October, 2013 at 18/10/2013 14:10:01 -

Thx again Chloe Sagal,

I did as you told me and it work just fine . I use Active Picture and ini for loading external images. And it work great .

One more thing: When i upload external image with Active Picture I can't set transparency. Problem is that my player wouldn't collide with invisible part of image. Is there any other solution to that?



Edited by Toni Montano

 
n/a

Chloe Sagal

under the influence of FUN

Registered
  19/02/2009
Points
  607

Orange
18th October, 2013 at 18/10/2013 16:44:38 -

I'm glad I was able to help

One of the other pitfalls, you have to set the image transparency externally, meaning that it'll have to be a .png 24 as opposed to a .png 8. I know photoshop and Gimp should allow you to do this.

Unless I just don't understand how to use it correctly.

EDIT: oh ha, there was another post, sorry, I'll answer that in a second.

Edited by Chloe Sagal

 
Patreon: http://www.patreon.com/chloesagal
Twitter: https://twitter.com/ChloeSagal

Toni Montano



Registered
  13/10/2012 05:35:39
Points
  15
18th October, 2013 at 18/10/2013 17:43:01 -

Ok, maybe i didn't write it right. Problem is that my player colides with invisible part of image. I did change to png 24 but is still the same.

 
n/a

Chloe Sagal

under the influence of FUN

Registered
  19/02/2009
Points
  607

Orange
19th October, 2013 at 19/10/2013 19:59:43 -

I wasn't able to figure it out, sorry.

 
Patreon: http://www.patreon.com/chloesagal
Twitter: https://twitter.com/ChloeSagal

The_Antisony

At least I'm not Circy

Registered
  01/07/2002
Points
  1341

VIP MemberStarSnow
12th November, 2013 at 12/11/2013 15:09:52 -

If the player is colliding with the transparency in your PNG, it's probably because you're either testing collisions with the active picture object itself, or whichever external image editor you used to create the PNGs didn't save transparency correctly. I'm not sure if your PNG is supposed to move or animate in-game, but if it's just static, paste the Active Picture as a background obstacle and test collisions with background like usual.

 
ChrisD> Employer: Say, wanna see a magic trick?
ChrisD> Employee: Uhh… sure, boss.
ChrisD> Employer: Your job! It just disappeared! Pack your things and leave! Pretty good trick, huh?

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49667

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
12th November, 2013 at 12/11/2013 17:18:53 -

I encountered this issue with the Animated Picture Object.
Turns out it didn't support fine collisions, so Yves sent me a modified version that did and it fixed my issues.

Might be that the active picture object doesn't support fine collisions directly. I have seen a game that used a collision mask instead and used a custom collision detection system using the overlay object to check for collisions. I'm sure something similar could be done with the surface object.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click