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.

AppGameKit Classic Chat / Endless Runner game logic

Author
Message
Custelinha
9
Years of Service
User Offline
Joined: 23rd Aug 2015
Location:
Posted: 23rd Aug 2015 10:14
Hello, it's my first time in AppGameKit
I wanna create an Endless runner game type (like banana kong, zombie tsunami) for android and ios, but I have two questions...

In the game, the scene is infinite, enemys, itens, holes, coins and background are randomly generated, but how can I do it? Whats the logic in it?
For the enemy and itens is easy, because it won't spaw in many positions, and in only one location (on the floor)... But how can I generate holes and coins randomly? The coins appers in any random position, and some times in horizontal or vertical.

Thw other question: How make game to run in all Android screens resolutions?

img attached.

Attachments

Login to view attachments
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 23rd Aug 2015 16:12
these questions are not really related to AGK

they are related to making an endless runner in any engine, so if you're going to use any other SDK, you're going to run into the same questions.

Check out the past NEWSLETTERS, I am sure you will find something similar to what you want.

For Screen resolutions, search for the most popular screen res being in use right now, and make 2d artwork for that. AppGameKit will automatically resize
Cor
AGK Developer
13
Years of Service
User Offline
Joined: 19th Dec 2010
Location: Its a trap!
Posted: 23rd Aug 2015 18:29
Hello custelinha,
welcome to the wonderful world of agk!

logic for the endless runners i have made goes somewhat like this... Make a platform, subtract the x value until its no longer visible. when its "scrolled" past the screen, you respawn it at the other side giving the illusion that its endless but its really just 2 or 3 scrolling images.

same concept applies to coins, items, enemies etc.

follow this tutorial http://code.tutsplus.com/series/corona-sdk-build-an-endless-runner-game-from-scratch--mobile-22913

even though its code is for a different engine, the tutorial goes over the logic to make the runner and its very straightforward to convert to agk code!
Paronamixxe
AGK Bronze Backer
12
Years of Service
User Offline
Joined: 10th Feb 2012
Location: Sweden
Posted: 23rd Aug 2015 18:32
The "holes" and coins can be added pretty much the same way as enemies.

With "holes", I'm guessing that you mean gaps in the terrain that players can fall through? In that case you could just have say 10 different terrain pieces and at runtime randomly select the next terrain piece. These could contain "holes", or have "holes" between them.

Coins are simple, just spawn them at intervals and place them X above the terrain.

Hope this helps.

cheers
Custelinha
9
Years of Service
User Offline
Joined: 23rd Aug 2015
Location:
Posted: 26th Aug 2015 03:44
Quote: "
The "holes" and coins can be added pretty much the same way as enemies.

With "holes", I'm guessing that you mean gaps in the terrain that players can fall through? In that case you could just have say 10 different terrain pieces and at runtime randomly select the next terrain piece. These could contain "holes", or have "holes" between them.

Coins are simple, just spawn them at intervals and place them X above the terrain.

Hope this helps."


What I do about the "falling down" in holes?
If I put physic in the terrain, it cover all the terrain sprite (holes included), What I do about the holes? How can I make diferent physic in the hole (gaps) part of the sprite?
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 26th Aug 2015 09:41
I wouldn't use physics for a game like this. You can use sprite collision detection to identify events such as collecting coins and falling down holes. Holes can be represented by a hidden sprite, which you detect collision with.

Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Custelinha
9
Years of Service
User Offline
Joined: 23rd Aug 2015
Location:
Posted: 3rd Sep 2015 10:12
Now I have an problem in the "jump effect"
I using physics, because my terrain have random heigth and random sprite.
And It has an item that temporarily increases the gravity
I already added shapes and the terrain are randomized great.

But I can't got the player to jump perfectly.
I set an WTF Y impulse value, but my player won't jump to high.
My player won't move, only the terrain move, because of it, he only jump to the Y position (just for up)

Gravity:


Impulse:


See the attached img, the player jump only to that position.

Attachments

Login to view attachments
Crazy Programmer
AGK Developer
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Lost in AGK
Posted: 3rd Sep 2015 19:07 Edited at: 3rd Sep 2015 19:08
Check Out: http://forum.thegamecreators.com/?m=forum_view&t=214699&b=41
Read Funells Posts...The guy is brilliant.

Down towards the bottom of the thread he has a really nice example of how to Jump and move.

http://crazyprogrammerproductions.webs.com/
Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 6th Sep 2015 23:21 Edited at: 6th Sep 2015 23:25
Here is a
that looks big, but that is only because of the white space and comments used for explanation.

This example is not the best, and could surely be done better way.
However, this way uses physics for a basic setup, and didn't take too long to whip up.
I used for loops here to make the ground for this example, but I would do this differently for loading levels from data files.
So, focus on the jump stuff and collisions, because that is what the example is supposed to help with.

I wasn't happy with my jump the first time I attempted a platformer, so I have been meaning to give this another go.
It isn't much, but I hope it helps in some way.

I have attached a zip that has the source and some media for watching it go.


Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1

Attachments

Login to view attachments
Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 7th Sep 2015 23:41 Edited at: 8th Sep 2015 00:47
Well, I couldn't resist...
Here is an expansion of that example above, only this time I am loading the ground from a text file and making it scroll endlessly.
(see attached)

I know you you have yours being done randomly, but I thought others might get a kick out of this loading madness.
Anyway, this little piggy is an endless runner. lol

This one uses 204 sprites for the canvas, and I thought of a way of optimizing the collisions test afterwards.
Right now I am looping all the sprites, but that is a bit taxing.
Since our runner is in the middle of the screen, we really only need to check for colliding with the 2 columns of sprites in the center.
So in pseudo (untested), the collisions might be...


which is check the top row of 17 sprites to see which ones are in the center of the screen.
Then checking those two columns only of 12 sprites each for 24 sprites.
The 17 and 24 are only checking 41 sprites, instead of looping through all 204 of them.
It isn't that clean but it should be faster.

Edit
I only just now watched a video of Banana Kong...


...that game looks really cool.
Very inspiring. (now I want an umbrella for the piggy for the hold on descend of jump)
Best of luck on this project.


Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1

Attachments

Login to view attachments
Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 8th Sep 2015 03:13 Edited at: 8th Sep 2015 03:31
Okay, since I already had the jump descending flag built in, adding in a drifting glide was easy enough.
I changed the increment/decrement on the ground sprites for scrolling movement to a variable, so the parachute has a better effect.
I have it set up so it works from heights greater than the ground level based on the jumps starting point.
Anyway, give it a try and let me know what you think... (see attached)


Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1

Attachments

Login to view attachments
Crazy Programmer
AGK Developer
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Lost in AGK
Posted: 8th Sep 2015 04:15
Really cool stuff Conjured! I tried forever to get to the top platform and failed I didn't even know if you could make it up there, I figured it was just for demonstration purposes

Sweet work with the parachute!

Beta Test Age of Knights:https://play.google.com/apps/testing/com.CrazyProgrammerProductions.my_AgeOfKnights
Download JellyFish Dive:https://play.google.com/store/apps/details?id=com.CrazyProgrammerProductions.my_JellyFishSwim
Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 8th Sep 2015 14:54 Edited at: 8th Sep 2015 16:50
Quote: "I tried forever to get to the top platform and failed I didn't even know if you could make it up there, I figured it was just for demonstration purposes"

Yeah, that one is a little out of reach.
I am glad someone finally tried it.
It didn't turn about too bad for about 200 lines.
I may try it a bit different on the ground tiles the next time though.
Right now I am placing sprites where the blanks are and just hiding them, but it would be better if I skip that area instead.
That would make for a much larger map, but this works for demonstration of the jump.

The 3 way jumping flag seems to be working okay so far.

jumping = 0 means we are not jumping at the moment and we are on the ground
jumping = 1 means we are jumping but have not reach the peak of our jump
jumping = 2 means we have reached the jump's apex and we are descending

If I take out the check for air jumping, then it works like the flapping controls found on games like flappy bird and super mario.
That section could be flagged to in order to turn the check off if we had picked up wings, etc.
You could reach that top platform then, but I will save that for later.
I have posted enough in this thread, and I don't think it is helping Custelinha much, because they have not said anything.
Maybe this example would make a good WIP thread, or something.
Maybe I make a video for those who have not tried the ZIP.

Quote: "Sweet work with the parachute!"

Thanks




Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1
SpecTre
Developer
21
Years of Service
User Offline
Joined: 24th Feb 2003
Location: UK
Posted: 8th Sep 2015 21:57
Quote: "Maybe this example would make a good WIP thread, or something."


Hey CE get it on there, love it! I recognise that little pig too as I saw him in a hot air balloon

Great game

Everyone is making a game at the minute, what with you and Crazy Programmer at it, you are giving me lots of inspiration guys

Definitely going to make a game next when these loose ends are finished off in my current projects!!

Well done and look forward to seeing this in the Show case/WIP section.

The Amiga and Amos were great!
My website LEAP - Download Paint Pot here!
Crazy Programmer
AGK Developer
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Lost in AGK
Posted: 8th Sep 2015 22:34
I would love to contribute to an Open Source Community Project.
Its always a good teaching / learning process for everyone. Including the pros getting the opportunity to see the same things done in a different way.

Beta Test Age of Knights:https://play.google.com/apps/testing/com.CrazyProgrammerProductions.my_AgeOfKnights
Download JellyFish Dive:https://play.google.com/store/apps/details?id=com.CrazyProgrammerProductions.my_JellyFishSwim
Custelinha
9
Years of Service
User Offline
Joined: 23rd Aug 2015
Location:
Posted: 9th Sep 2015 04:10
I'm sorry for not answering , I was traveling.
I will take a look at your code Conjured Entertainment, seems pretty good!
Custelinha
9
Years of Service
User Offline
Joined: 23rd Aug 2015
Location:
Posted: 9th Sep 2015 08:10
Conjured Entertainment, I read your code, and now can implement JUMP using your logic,
You're greate

When I finish the game, I post here. But it will take some times... I stopped at the part that have to add Shape Poligon at the player sprite, it's so hard
Crazy Programmer
AGK Developer
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Lost in AGK
Posted: 9th Sep 2015 15:27
Your going to need Polygon for accurate collisions. If you are making a platform game and your character is randomly dying when he obviously was not hit or getting stuck places he is obviously not touching...People will get mad

I dont remember the exact command to set it to Polygon shape if i remember there is more than one way to do it.

SetSpriteShape(Character,3)

or is it SetSpritePhysicsShape(Character,3)

If i was on my Dev Computer i could tell you exactly but im sure its one of those.

Beta Test Age of Knights:https://play.google.com/apps/testing/com.CrazyProgrammerProductions.my_AgeOfKnights
Download JellyFish Dive:https://play.google.com/store/apps/details?id=com.CrazyProgrammerProductions.my_JellyFishSwim
Custelinha
9
Years of Service
User Offline
Joined: 23rd Aug 2015
Location:
Posted: 9th Sep 2015 22:03
Quote: "Your going to need Polygon for accurate collisions. If you are making a platform game and your character is randomly dying when he obviously was not hit or getting stuck places he is obviously not touching...People will get mad

I dont remember the exact command to set it to Polygon shape if i remember there is more than one way to do it.

SetSpriteShape(Character,3)

or is it SetSpritePhysicsShape(Character,3)

If i was on my Dev Computer i could tell you exactly but im sure its one of those."


It is SetSpriteShape(player, 3), but it set the polygons where I do not want, because of this I need to set the polygons manually, but this is very hard
Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 10th Sep 2015 04:17 Edited at: 10th Sep 2015 04:21
Quote: "Conjured Entertainment, I read your code, and now can implement JUMP using your logic,"

Cool
I am glad I could help.

Quote: "
Hey CE get it on there, love it! I recognise that little pig too as I saw him in a hot air balloon"

Yeah, I am still working on more levels for "Angry Piglets: Revenge of the Swine!". (that is where he is from originally)

Quote: "I would love to contribute to an Open Source Community Project."

Me too!
I think Baxslash has already contributed to any open source community project, because it would definitely need to use PAX.

Quote: "Its always a good teaching / learning process for everyone. Including the pros getting the opportunity to see the same things done in a different way."

Yeah, they can get to see how I code, fubar style.

Here is a surprise using the tab key... (see attached)

I didn't include the source for this installment because I have not cleaned it up, so it wouldn't be a good code example.
However, I was pleasantly surprised at how easy it is to implement particles using Baxslash's PAX particle editor.
So, instead of a laggy video, I will just let you give it a run and see what you think, just be careful using that tab key.


Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1

Attachments

Login to view attachments
Crazy Programmer
AGK Developer
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Lost in AGK
Posted: 10th Sep 2015 04:30
Sweeet stuff Conjured! The effects are amazing!

Iv managed to figure out how to walk on air

If you are hitting the jump button and the side arrow keys fast enough while walking off the end of a platform.
The pig does not jump and just walks on air a good ways before he floats to the ground

Beta Test Age of Knights:https://play.google.com/apps/testing/com.CrazyProgrammerProductions.my_AgeOfKnights
Download JellyFish Dive:https://play.google.com/store/apps/details?id=com.CrazyProgrammerProductions.my_JellyFishSwim
Conjured Entertainment
AGK Developer
19
Years of Service
User Offline
Joined: 12th Sep 2005
Location: Nirvana
Posted: 10th Sep 2015 04:45 Edited at: 10th Sep 2015 05:00
Quote: "If you are hitting the jump button and the side arrow keys fast enough while walking off the end of a platform. "

Yeah, I was getting sloppy towards then end, hence the need to clean the code up.
The goal was to get a bomb working using particles.
Those crates are not being blown up as good as they could, so they need tweaking too.
I think that problem you are encountering is due to my poor handling of collisions with the ground.

I think I will start over from the beginning anyway, because I thought of a better way of mapping and loading the level.
At least the jump helped him, so it served its purpose.

Quote: "The effects are amazing! "

I have to thank Baxslash for that.
Did I mention that I used his PAX Particle Editor?
Seriously though, I really need to go back and improve my existing games with PAX.


Coding things my way since 1981 -- Currently using AppGameKit V2 Tier 1
Custelinha
9
Years of Service
User Offline
Joined: 23rd Aug 2015
Location:
Posted: 19th Sep 2015 04:15
Now I have a problem... This problem has existed since the beginning of the project

Now working great (Thanks Conjured Entertainment ), but I'm with lag issues.

Conjured Entertainment, my logic for the terrain generation is totally different from yours, I have 7 sprites that representing the terrain, all that sprites are stored in an array. I use other array to show the actual terrain (this is the main array of terrain), and this array only store two sprites, every time an sprite of this array (terrain) go to out of screen, I randomize an number to know what the next sprite to put in the main terrain array.
But some times when an sprite of the main terrain array go out the screen, I notice some lag!!

All terrain sprites have the same width and heigth, and use the same weigth of the screen, I use seven sprites for terrain because I use the holes in the sprites and draw the shapes in the sprite, except in the part of holes...

Look at the code:

in the main loop:
terrenosArray = Main terrain array
if(inicioCenarioCount<TERRENO_PRIMEIROS_STEPS) - The random function start only when the first terrain go of the screen 3 times
terrenoTamanhoRandom - This is the random function for the terrain


The random function:


The main terrain sprite array:


The terrain sprite array:
Yeah, its is WTF... But I could not think of another logical for the random, I set the min and max value for each terrain sprite, and randomize. Ex: If I the random number is 60, then I get the dadosTerrenosArray[2], because the number is betwen 51 and 80


Sorry for the bad code, I'm a java programmer, I know nothing about game programming
And I know it's hard to understand the code because the variables are in Portuguese, sorry, I do not like using abbreviations, they confuse me

Login to post a reply

Server time is: 2024-11-25 18:04:37
Your offset time is: 2024-11-25 18:04:37