Would like help with two things
-
Hi, I have two questions.
1 - How do I make a radar like in Defender where it shows the player and all the enemies even ones offscreen?2 - platform game, I am using map collision to stop a player falling through the ground but the player sinks into the ground by 1-2 pixels which does not look good. What I want to do is have the player dropping down until he is 1 pixel above the ground and stop there. how to do it?
-
-
When your player hits the ground, set his vertical position 1 pixel above the area.
See getMapArea() to retrieve the coordinates. -
@Sgtelite78 To answer the radar question, you'll could use draw targets to achieve this. Think of them like separate little screens which you put on screen in an order of your choosing:
radarScreen = createImage(600, 300, image_rgba) // This creates an image of 600 by 300 pixels, with transparency enabled mainScreen = createImage(gwidth(), gheight(), image_rgba) // This is your main screen which will eventually be sent to the frame buffer - width and height are whole screen width/height //then, in your loop, you would probably want a function which draws everything to the screen. loop // game code draw() repeat function draw() setDrawTarget(radarScreen) clear() // draw enemies and player to this screen scaled down, or as "dots" - in defender style setDrawTarget(mainScreen) clear() drawImage(radarScreen, gwidth()/2 - 600, 0) // draw the radar to your main screen image // the rest of your drawing, enemies, player, etc. These could also be in their own draw targets for total control // finally, draw your main screen to the frame buffer setDrawTarget(frameBuffer) drawImage(mainScreen, 0, 0) update() return void
I've put a
clear()
command after eachsetDrawTarget()
because it's a catch all for problems you might face without them. Sometimes it's not necessary, but it's safe to assume you'll need them.The "Ninja Scroll" game uses separate draw targets and compiles them into an image in a similar way I've listed here, if you wanted an example. It doesn't do anything like a radar display, however.