Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / Randomized building decorations

Author
Message
Jaeg
18
Years of Service
User Offline
Joined: 16th Mar 2006
Location: Indiana
Posted: 28th May 2016 22:06
I'm working on a side scrolling beat'em up and I was wanting the buildings in the background to have randomized window and door placements. In other languages I could do this simply but defining an offset for each window or door and then drawing the image directly with the offset and building position. However in AppGameKit that type of functionality is being handled internally and positions can only be given to sprites themselves.

So when I generate a building would I need to create a set of sprites, keep track of which belong to a specific building, then iterate through them to update their positions in relation to the building?
Go ahead. Walk into Mordor.

Ball State University - Computer Science Major
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 28th May 2016 23:26 Edited at: 28th May 2016 23:29
you could use memblocks to "burn" the windows into each building.
this is some code i used to emulate the copyimage command (before i knew there was a copyimage() command haha)
i think it would be a good start to making something like you want
https://forum.thegamecreators.com/thread/193433?page=6#msg2579666
Jaeg
18
Years of Service
User Offline
Joined: 16th Mar 2006
Location: Indiana
Posted: 29th May 2016 00:01 Edited at: 29th May 2016 00:21
I hadn't thought of using a memblock! I'll play with it and report back. Thanks!



*EDIT*
First off I'm sorry for pretty much just stealing your line of code where you set the memblock data. Works like a charm as long as the x is positive. For my purposes I'm not too worried about getting it to work with negative x's for now.

Thanks again!
Go ahead. Walk into Mordor.

Ball State University - Computer Science Major
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 29th May 2016 03:10 Edited at: 29th May 2016 03:11
you're welcome. i'd love to see the results when it's finished!

if you run into performance issues you might want to try CopyMemblock() rather than a byte by byte copy
Jaeg
18
Years of Service
User Offline
Joined: 16th Mar 2006
Location: Indiana
Posted: 30th May 2016 01:35 Edited at: 30th May 2016 04:57
Off topic but is there an issue with CopyImage? I'm using it to pull apart a spritesheet that contains the building parts but occasionally it seems to fail or crashes the app.



*EDIT* Uploaded an image of what the game looks like right now. Currently the only thing decorating the buildings are the randomly placed doors. lol
It can actually scroll. There are three buildings and when one leaves the screen it assigns it a new randomly generated image to keep it from looking the same every time the building goes by.

Currently I'm running into an issue with CopyImage and my previous statement of it crashing the game is wrong. It just doesn't have any image data for whatever reason and it causes the building to be invalid. It seems to be random if CopyImage works or not for me.
Go ahead. Walk into Mordor.

Ball State University - Computer Science Major

Attachments

Login to view attachments
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 30th May 2016 05:17
copyimage the command or the copyimage function
this should help if it's the copyimage() command;
https://forum.thegamecreators.com/thread/217196
Jaeg
18
Years of Service
User Offline
Joined: 16th Mar 2006
Location: Indiana
Posted: 30th May 2016 05:58
CopyImage the command.


Most of the time it works but there are times where it seems like it just fails between multiple runs of the program without actual code changes.
Go ahead. Walk into Mordor.

Ball State University - Computer Science Major
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 30th May 2016 06:49
could you create a demo of the problem maybe?

Login to post a reply

Server time is: 2024-11-21 20:21:39
Your offset time is: 2024-11-21 20:21:39