- ** Sorry guys! I had this all nicely tabbed and spaced, but when I click ‘submit’ it gets all screwed up? The only way I can get it to work, is to use bullet points **
- Apparently my most recent post was lost/removed after the update to the Forums… :huh:
- Rather than creating multiple threads, I’ve decided to re-post my previous question in addition to a few other things I’d like to assistance with.
- I am working on three different projects simultaneously - I know, I know… bad idea
- so my questions might seem a little chaotic in order.
-
* I apologize in advance as this post will most likely be fairly long.
*
- First , this is a video of the game I’m trying to replicate - obviously with my own twist/look - link
- After exchanging a few posts between some people, it was looking as if my best bet would be to create a grid with walkable areas/squares that have a value of 0 and the squares with obstacles - generated via LevelHelper - a value of 1.
- Per the suggestion of one “commenter”, I started messing around with the Jumper library, and while it looked as if it would be what I needed the explanations/docs were a little vague for a novice programmer like myself.
-
Q1) How would I make a grid that overlays the entire display, and how would I code my enemy tanks to roam around randomly constrained to the squares with a value of 0 - so as to avoid the obstacles. I originally thought to use the A* Algorithm but I decided against it to because I don’t want the tanks to have a set goal/destination, rather just aimless roaming behavior like seen in the video.
- Second bit - My third project I am currently working on is an infinite side-scroller, and I’m wondering what is the best way to generate random enemies?
- Like DoodleJump in the sense that my enemies will be appearing from the left and in random positions, formations, moving randomly etc…
- I know of several ways to code this, but I am wondering what the common practice is in this type of scenario…
- Q1 ) What is the best way to code enemies on a side-scroller? Again, like how DoodleJump has platforms being continuously generated and the difficulty progressively getting harder after a certain amount of time.
- Do I just code the enemies to spawn randomly just past the display and then code the desired movement or do I make a really long ‘level’ via LevelHelper?
- Final question -
- This is really bugging me… I’ve been trying to get my tank to fire a bullet, but it’s not working quite right.
- The problem is that no matter what direction I choose to fire my turret, the bullet appears facing whatever direction the bullet ‘image’ is facing.
- e.g. say I tap on a location near the top of the display to fire, the tank position being the bottom-center of the display, now the bullet ‘image’ has the bullet pointing to the right and when I fire that’s how it shows up…? traveling to the spot I told it to fire, but with its original rotation…
- I tried matching the image rotation to whatever the turret’s rotation happen to be, but that didn’t work?!
- Is that what this type of graphic is for, firing in different directions?
Any bit of help would be greatly appreciated!
Hi
for the “infinite side-scroller” --> http://www.raywenderlich.com/4885/how-to-make-a-game-like-doodle-jump-with-corona-tutorial-part-1
Not sure if it would help 
Note: Please check your message inbox (in the coronalabs website)
Thanks 
Thanks, I’ll take a look.
- I checked, and replied -
Well these are obviously topics that people are interested in, seeing as there are over 110 views…
Any of you more experienced programmers/developers care to weigh in?
I don’t have any real advice for the first one. For a similar app I used the physicsEditor on the background image and it basically let me mark all my walls. Then I used collision detection to keep my car on the road. The video of what you’re trying to do seems like this might be a good approach. Use objects like the walls as static physics objects and then move your enemy tanks until it his something randomly turning it.
For your second question I’ve done it two ways. One app I had two backgrounds that were seemless and just scrolled constantly. I would spawn the enemies off screen and the move them on screen as necessary. They were just randomly created as needed. In another game, I strung 4 backgrounds into one single large scroll object and moved it as my player moved. But in that case I pre-populated all the objects when the level was created. They were still randomly distributed because I stink at level design. Either works depending on your needs.
For the last question you could do:
[lua]
bullet.rotation = tank.rotation
[/lua]
and that should rotate the bullet at the same angle as the tank. The graphic you posted sort of does that, it gives you pre-rotated graphics. The reason you might want that is because of lighting. It’s demoed best in the 2nd block from the top left. If you take the SW position and just rotated it, it would not be the same ad the NE one. So if shadows, highlights or textures would be weird with just rotation, then you would want something like this. But if you look at the one in the bottom right, it just doesn’t matter.
Thanks for replying, Rob. 
Okay, that sounds like a good plan.
Using the code in this: link I should be able to set all my walls and obstacles with the same ‘tag’ - which should make collision handling quite a bit easier.
- Just to clarify - I would have a function for transitioning my Etank/s randomly within the level, and then when my Etanks collide with a wall or obstacle I would code them to either change their rotation or transition.to a new random location? Does that sound right?
Awesome, that’s pretty much the direction I was headed.
Would it be “programmatically” correct to at some point within the game pause the function (randomly spawning enemies past the display), and start a new function that would spawn enemies in specific formations and after a set amount of enemy “waves” stop the function and resume the original function?
Would I setup some kind of a timeElapsed variable?
lol in past attempts, I must have had some conflicting code because the code you posted works fine now. :]
Only thing, the bullet’s rotation does not change to match its new dirction of travel after it ricochets?
Thanks for clearing things up about the graphic; I was always a bit curious as to the purpose of those types of images. 
Any bit of help would be greatly appreciated!
Hi
for the “infinite side-scroller” --> http://www.raywenderlich.com/4885/how-to-make-a-game-like-doodle-jump-with-corona-tutorial-part-1
Not sure if it would help 
Note: Please check your message inbox (in the coronalabs website)
Thanks 
Thanks, I’ll take a look.
- I checked, and replied -
Well these are obviously topics that people are interested in, seeing as there are over 110 views…
Any of you more experienced programmers/developers care to weigh in?
I don’t have any real advice for the first one. For a similar app I used the physicsEditor on the background image and it basically let me mark all my walls. Then I used collision detection to keep my car on the road. The video of what you’re trying to do seems like this might be a good approach. Use objects like the walls as static physics objects and then move your enemy tanks until it his something randomly turning it.
For your second question I’ve done it two ways. One app I had two backgrounds that were seemless and just scrolled constantly. I would spawn the enemies off screen and the move them on screen as necessary. They were just randomly created as needed. In another game, I strung 4 backgrounds into one single large scroll object and moved it as my player moved. But in that case I pre-populated all the objects when the level was created. They were still randomly distributed because I stink at level design. Either works depending on your needs.
For the last question you could do:
[lua]
bullet.rotation = tank.rotation
[/lua]
and that should rotate the bullet at the same angle as the tank. The graphic you posted sort of does that, it gives you pre-rotated graphics. The reason you might want that is because of lighting. It’s demoed best in the 2nd block from the top left. If you take the SW position and just rotated it, it would not be the same ad the NE one. So if shadows, highlights or textures would be weird with just rotation, then you would want something like this. But if you look at the one in the bottom right, it just doesn’t matter.
Thanks for replying, Rob. 
Okay, that sounds like a good plan.
Using the code in this: link I should be able to set all my walls and obstacles with the same ‘tag’ - which should make collision handling quite a bit easier.
- Just to clarify - I would have a function for transitioning my Etank/s randomly within the level, and then when my Etanks collide with a wall or obstacle I would code them to either change their rotation or transition.to a new random location? Does that sound right?
Awesome, that’s pretty much the direction I was headed.
Would it be “programmatically” correct to at some point within the game pause the function (randomly spawning enemies past the display), and start a new function that would spawn enemies in specific formations and after a set amount of enemy “waves” stop the function and resume the original function?
Would I setup some kind of a timeElapsed variable?
lol in past attempts, I must have had some conflicting code because the code you posted works fine now. :]
Only thing, the bullet’s rotation does not change to match its new dirction of travel after it ricochets?
Thanks for clearing things up about the graphic; I was always a bit curious as to the purpose of those types of images. 