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 / Make a map and minimap like metroid/castlevania?

Author
Message
Yaro
5
Years of Service
User Offline
Joined: 29th Mar 2014
Location:
Posted: 11th May 2015 07:46
I'm building a game with elements from Metroid and Castlevania, namely rooms filled with enemies and (later) power ups. I have the rooms working in a nice system, and doors are automatically created between adjacent rooms. What I'd like to do is create a map and minimap that reflect the surrounding rooms. I feel like I need to use rendertoimage, but I'm not sure quite how I'd get started with attempting this. I'd eventually like to display doors, and only show rooms that the player has knowledge of, but I feel like the main challenge is getting the map created and displayed in the first place. Can anybody give me a little guidance?
Yaro
5
Years of Service
User Offline
Joined: 29th Mar 2014
Location:
Posted: 11th May 2015 07:48
A little more information, I have room width and height set as screen lengths as an integer, and currently rooms are only rectangles. Hoping it shouldn't be too complicated.
baxslash
Valued Member
Bronze Codemaster
12
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 11th May 2015 10:00
A relatively easy way to do this would be to use RenderToImage as you suggested. Here are the steps.

1-Create an image that is the correct size let's say 256x256 (it's best to stick to power of two images)

2-Create a sprite using this (currently blank) image and position it where you want your minimap
3-Create a function to draw to the image to be called during the game loop

3 is the hard part so here's a rough idea taking for granted that you have your room data in a UDT array:

This could be extended and improved a lot by adding corridors, checking rooms are within the scope of the minimap and more... hope it helps!

Using AppGameKit V2 Tier 1
Yaro
5
Years of Service
User Offline
Joined: 29th Mar 2014
Location:
Posted: 11th May 2015 10:32
The code you submitted is extremely useful, thanks! I also didn't know you could create colors like that, sounds a lot more convenient than the method I've been using. I'll try to incorporate this into my project and let you know how it goes. Thanks
Yaro
5
Years of Service
User Offline
Joined: 29th Mar 2014
Location:
Posted: 12th May 2015 10:14
I'm getting the image made, but I'm having a rough time getting my screen back to normal. I'm using the percentage system without any setvirtualresolution settings. How can I revert back to this after rendering to image?
Yaro
5
Years of Service
User Offline
Joined: 29th Mar 2014
Location:
Posted: 12th May 2015 10:18 Edited at: 12th May 2015 10:21
Found out the problem immediately after posting , just needed to call SetDisplayAspect again after calling SetRenderToScreen.
baxslash
Valued Member
Bronze Codemaster
12
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 12th May 2015 11:15
Ah, yes. I don't tend to use the percentage system any more. Not sure why as it should be simpler...

Using AppGameKit V2 Tier 1
Yaro
5
Years of Service
User Offline
Joined: 29th Mar 2014
Location:
Posted: 13th May 2015 00:22 Edited at: 13th May 2015 00:22
I'm hitting a few snags. I've made the code work with my program, but I can't figure out why I'm getting these problems.

My relevant code:


On PC, I get a result that looks like this:


On android (both broadcasting and installing an apk), I get a result that looks like this:


Any tips/advice?
Yaro
5
Years of Service
User Offline
Joined: 29th Mar 2014
Location:
Posted: 13th May 2015 11:38
I was able to fix the horizontal spacing by using the line


Attempting a similar approach to the vertical gap did not work, and neither did increasing the y2 value. It's still appearing very faulty on android.
Yaro
5
Years of Service
User Offline
Joined: 29th Mar 2014
Location:
Posted: 16th May 2015 09:33
Ok so I've hit a brick wall with this problem, and decided to make a stripped-down bare bones project that makes the minimap. I failed, and get results similar to before. At this point, I'm not entirely convinced it's a problem on my end, although I'd be very happy if I could fix it by adding/changing a few lines of code. Could anybody run the code on their end and see if they get similarly messed up results? The zipped project is attached, thanks in advance.

Attachments

Login to view attachments
baxslash
Valued Member
Bronze Codemaster
12
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 18th May 2015 08:43
I will have a look. Been busy...

Using AppGameKit V2 Tier 1
Yaro
5
Years of Service
User Offline
Joined: 29th Mar 2014
Location:
Posted: 18th May 2015 09:13
Not sure how/why, but when I changed the render image from 512x512 to 800x450 (keeping with my aspect ratio) it fixed the issue with the gaps. I'm still getting some weird visual artifacts when I run it on android. Thanks for taking another look baxslash!
baxslash
Valued Member
Bronze Codemaster
12
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 18th May 2015 19:11
Sorry, ran out of time again today! I'll try again tomorrow...

Using AppGameKit V2 Tier 1
Yaro
5
Years of Service
User Offline
Joined: 29th Mar 2014
Location:
Posted: 19th May 2015 03:28
No worries, I've had a lot going on too, finals and whatnot.
IronManhood
4
Years of Service
User Offline
Joined: 6th Feb 2015
Location: US
Posted: 19th May 2015 04:26
It might have something to do with agk automatically adding in padding(black bars).
Yaro
5
Years of Service
User Offline
Joined: 29th Mar 2014
Location:
Posted: 19th May 2015 11:33
Yeah, that makes sense. It is working with PC after I changed the rendertoimage resolution to match the aspect ratio of my app, but it's still appearing glitchy and full of bars on android. If I could just get it working on Android like I currently have it working on PC then I'd be happy.
baxslash
Valued Member
Bronze Codemaster
12
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 19th May 2015 13:07
I'm having trouble getting the rooms to look correct. There's something screwy with aspect ratios here. I normally only use virtual resolution these days and I am worried there might be a problem with using the percentage system. Alternatively I might just be tired...

Using AppGameKit V2 Tier 1
Yaro
5
Years of Service
User Offline
Joined: 29th Mar 2014
Location:
Posted: 20th May 2015 10:48
Well I tried running it again with using virtual resolution, and I'm no longer getting any issues with zapped images. Thanks a bunch baxslash! I didn't have any strong preferences between the two, so now I have a good reason.
Yaro
5
Years of Service
User Offline
Joined: 29th Mar 2014
Location:
Posted: 25th Jul 2015 23:36
Just to help people who may be looking for something similar, SetRenderToImage has been not working for me when the resolution is something other than the virtual resolution the rest of my game is in. However, to crop it so it fits nicely, I've just implemented SetSpriteUV and now it's looking about as nice as I could ask for. Feel free to PM me if you run into any hiccups and I'll see if I can help.

Login to post a reply

Server time is: 2019-12-13 16:10:12
Your offset time is: 2019-12-13 16:10:12