Code Breakdown Please?

This forum is meant for posting anything related to Adventure Maker that doesn't fit in the other forums.Please post technical questions in the Technical Support Forum!

Moderators: time-killer-games, Vengeance66, Candle, reneuend, GM-Support

Code Breakdown Please?

Postby Netjera » Mon Jan 25, 2010 5:51 pm

I hate to be a bother, but I was wondering if someone could explain to me what's going on here:

Code: Select all
 "Level"+cstr(LevelNumber)+"_Tile"+cstr(Hotspot(TileNumber).tag)+".jpg"


I mean, obviously, we're putting together a picture name on the fly, but I'm not sure I'm understanding *how* and I don't know what "cstr" does. Would someone mind explaining, please?

Thanks!
A woman on a mission - a budding artist looking for a place to take root, a builder looking for the right community - I'm looking for a home.
User avatar
Netjera
Frequent Poster
 
Posts: 127
Joined: Sun Jan 24, 2010 8:48 am
Location: United States

Postby reneuend » Mon Jan 25, 2010 6:11 pm

Level"+cstr(LevelNumber)+"_Tile"+cstr(Hotspot(TileNumber).tag)+".jpg

outcome of this is: Level00_Tile0.jpg
where 0 could be any number

Cstr is used to convert the value in parenthesis to string format. VB is good about converting most things automatically, but this is good practice.
---


Image
Image
User avatar
reneuend
Administrator
 
Posts: 2762
Joined: Sat Nov 22, 2008 8:37 pm
Location: Midwest Cornfield, USA

Postby Netjera » Mon Jan 25, 2010 6:25 pm

reneuend wrote:Level"+cstr(LevelNumber)+"_Tile"+cstr(Hotspot(TileNumber).tag)+".jpg

outcome of this is: Level00_Tile0.jpg
where 0 could be any number

Cstr is used to convert the value in parenthesis to string format. VB is good about converting most things automatically, but this is good practice.


I guess I must be obtuse, because I don't see how it's working. *frowns at herself* If LevelNumber is a word, then how is it converting it into a number, and how does the programmer know that it will be the right number to call the picture he wants? o.O <--- really confused look
A woman on a mission - a budding artist looking for a place to take root, a builder looking for the right community - I'm looking for a home.
User avatar
Netjera
Frequent Poster
 
Posts: 127
Joined: Sun Jan 24, 2010 8:48 am
Location: United States

Postby reneuend » Mon Jan 25, 2010 7:19 pm

In my "perfect picture" puzzle game, I have 16 hotspots in a grid pattern. I purposely made the image names sequential like this:

img1_1.jpg
img1_2.jpg
...
img1_16.jpg


if i showed you the code it would look something like this:

"img" & cstr(puzzle_num) & "_" & cstr(hotspot_num) & ".jpg"

I have 6 puzzles, so I increment puzzle_num when a new puzzle needs to be displayed. puzzle_num = puzzle_num +1

To display all 16 parts of a puzzle, I use the hotspot_num to determine what image should be displayed in a specific hotspot.

Code: Select all
for hotspot_num = 1 to 16
    Action.LoadAPicture Hotspot(1), "img" & cstr(puzzle_num) & "_" & cstr(hotspot_num) & ".jpg"
next



so Action.LoadAPicture Hotspot(1), "img1_1.jpg" would load the image in hotspot 1 and so on.....

I hope that helps!
---


Image
Image
User avatar
reneuend
Administrator
 
Posts: 2762
Joined: Sat Nov 22, 2008 8:37 pm
Location: Midwest Cornfield, USA

Postby Netjera » Mon Jan 25, 2010 7:45 pm

reneuend wrote:In my "perfect picture" puzzle game, I have 16 hotspots in a grid pattern. I purposely made the image names sequential like this:

img1_1.jpg
img1_2.jpg
...
img1_16.jpg


if i showed you the code it would look something like this:

"img" & cstr(puzzle_num) & "_" & cstr(hotspot_num) & ".jpg"

I have 6 puzzles, so I increment puzzle_num when a new puzzle needs to be displayed. puzzle_num = puzzle_num +1

To display all 16 parts of a puzzle, I use the hotspot_num to determine what image should be displayed in a specific hotspot.

Code: Select all
for hotspot_num = 1 to 16
    Action.LoadAPicture Hotspot(1), "img" & cstr(puzzle_num) & "_" & cstr(hotspot_num) & ".jpg"
next



so Action.LoadAPicture Hotspot(1), "img1_1.jpg" would load the image in hotspot 1 and so on.....

I hope that helps!


Hmm... it might. I need to let it ferment a bit. Thanks!
A woman on a mission - a budding artist looking for a place to take root, a builder looking for the right community - I'm looking for a home.
User avatar
Netjera
Frequent Poster
 
Posts: 127
Joined: Sun Jan 24, 2010 8:48 am
Location: United States


Return to Adventure Maker General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests