Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411515 Posts in 69376 Topics- by 58431 Members - Latest Member: Bohdan_Zoshchenko

April 27, 2024, 04:43:33 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperDesignrandomizing a shoot em up?
Pages: [1]
Print
Author Topic: randomizing a shoot em up?  (Read 2315 times)
JasonPickering
Level 10
*****



View Profile WWW
« on: February 25, 2010, 09:34:07 PM »

alright so its not really a shoot em up more of a dodge em up, but anyways. I don't really know how to go about this and I wasn't sure where to post this.



so now I dont know how to make it so the game doesn't give you some level where you get stuck by the clouds and cant get out and die. do you guys just suggest leaving it the way it is? cause the game restarts rather quickly. or should i try and create some system where the player can always get through or should I make something where it takes you through specific sets of clouds that you always navigate the same way. I plan on speeding up the clouds as the game goes so keep that in mind to.
Logged

dustin
Level 6
*


View Profile
« Reply #1 on: February 26, 2010, 12:26:11 AM »

Whenever I've had to do this I've always plotted a path of the correct size for the charector randomly when generating the level then never put anything in that path that way there is always at least 1 way that the player can go through.
Logged
SirNiko
Level 10
*****



View Profile
« Reply #2 on: February 26, 2010, 06:59:33 AM »

You might also go the Spelunky route and give the player consumable items that allow them to break through obstacles that are otherwise impassable. Part of the strategy is then recognizing where you must use those items and when you can get by without.

Alternately, you might make it so that the game generates the level and then checks for possible paths after the fact (As opposed to generating the path first and generating the obstacles second as Dustin has suggested). Then it either gives the player enough items to get through, or regenerates the level again until it creates a set with at least one solution.

-SirNiko
Logged
JasonPickering
Level 10
*****



View Profile WWW
« Reply #3 on: February 26, 2010, 07:54:28 AM »

So where can I find a good tutorial on pathfinding in gamemaker.
Logged

JasonPickering
Level 10
*****



View Profile WWW
« Reply #4 on: February 27, 2010, 10:49:26 AM »

so I have been working on this more and I think one thing i need to mention is that the game really only has one level, it just goes on and on. canabalt would be a good idea to see what i mean. so the calculating a path and if it doesn't work recalculating i don't think that would work.
Logged

Tuba
Level 10
*****



View Profile WWW
« Reply #5 on: February 27, 2010, 07:58:16 PM »

If I understand it correctly.. you need the clouds positions to be random but they can't be all too close to each other so that the player can't pass, right?

I don't think pathfinding is really necessary here.. specially if you have only one infinite level like in Canabalt. Just generate a "wave" of clouds in random positions and verify if there's enough space between them so that the player can pass, that shouldn't be hard to do. You can generate new waves after a certain amount of time making your level infinte.

I hope that helps.
Logged

J. R. Hill
Level 10
*****

hi


View Profile WWW
« Reply #6 on: February 27, 2010, 11:53:40 PM »

Off topic: Oh man I love this game's aesthetics ten times more every time you change it.
Logged

hi
JasonPickering
Level 10
*****



View Profile WWW
« Reply #7 on: February 28, 2010, 03:11:53 PM »

so I'm still working with this, but I seem to be having a problem that it also depends on what the player is doing. it is possible for clouds to be made, but the player cant get through them because of ground. and if the player chose to go above the first cloud then a clear path is there. so i guess its back to the drawing board. I am not really good at procedural generation yet, so I guess this is a learning experience. i also tried making sets that the game puts one right after another, but the players choices again messed it up, as a path could be set for them one way but unknowingly if they choice the wrong way it might kill them further down the line. my eventual hope it so add other types of enemies, but i feel i need to get the clouds working perfectly first. well back to the drawing board.

JR Hill: thanks, i like the newer art style now, I need to update the feedback but this has thrown such a wrench in the gears that it has brought me to a dead halt.

P.S. it has ragtime music.
Logged

J. R. Hill
Level 10
*****

hi


View Profile WWW
« Reply #8 on: February 28, 2010, 03:26:18 PM »

That's fantastic.
Logged

hi
SirNiko
Level 10
*****



View Profile
« Reply #9 on: February 28, 2010, 08:15:24 PM »

Rather than randomly generating everything, randomly generate the obstacles in pre-planned chunks that you know the player can navigate.

For example, the game has three obstacles: a cluster of clouds, a thunderstorm, and an airplane. The game rolls the random die, and it decides on a cluster of clouds. It just copy/pastes the cluster of clouds onto the play area, and since you drew all those clouds in advance, you know it is navigable. After the player clears them, the game rolls again, and settles on a thunderstorm. Your pre-planned thunderstorm appears, and the player navigates it. Then it rolls one more time, and gets more clouds, so the same set of clouds appears a second time.

Does that make sense?

The upside is that this makes it easy to have all sorts of wacky, unrelated obstacles without having to code some complex algorithm to generate them in a sensible way. Not to mention, it solves the problem with making a path through them.

Difficulty can be increased by increasing the speed of the player, or by pulling obstacles from progressively more difficult pools (For example, after ten obstacles, the 'cloud' obstacle becomes more dense and harder to navigate, although it's still a pre-defined cluster of clouds you drew beforehand). It's really up to you!

-SirNiko
Logged
JasonPickering
Level 10
*****



View Profile WWW
« Reply #10 on: February 28, 2010, 08:34:59 PM »

you know i think that just might work.

*code code code*
Logged

Fallsburg
Level 10
*****


Fear the CircleCat


View Profile
« Reply #11 on: March 01, 2010, 07:47:27 AM »

The problem with doing the randomly choose a pre-planned bit of level and paste it in method is that unless you have a lot pieces, it's very easy to identify the pieces meaning that the game becomes boring quickly.

Here is a good article on rhythm based platform levels that is forming the basis of the level generation for my SHMUP:

http://portal.acm.org/citation.cfm?id=1536548
Logged
JasonPickering
Level 10
*****



View Profile WWW
« Reply #12 on: March 01, 2010, 09:24:15 PM »

thanks Tromack I will have to read that. it sounds really neat. right now I am trying something similar where a box goes ahead of the character putting in all the clouds. The box of course will be invisible and then they can just follow its path and then its a system of ups and downs kind of like the rhythm idea. I created one where the box moves in straight diagonals but I want something more like a sine curve and I am really having trouble with that. I want it to ease in and out and then select a new height and distance to move to. does anybody know how I can code it to get the sine curve to move up to a predetermined amplitude.
Logged

Sam
Level 3
***



View Profile WWW
« Reply #13 on: March 02, 2010, 05:16:24 AM »

The nice "easing in and out" part of a sine wave is from half pi to one-and-a-half pi.  So to make it a little neater, let's use cosine which does its easing from 0 to pi.

Here's some pretend-o-code that should work.

The key to the whole thing is the line:
boxY = toMultiplyCosineBy * cos((boxX - xPositionWhenTargetWasSet) * toMultiplyXBy) + toAddToAllThat;
Which makes the Y position of the box follow the cosine curve.  All the stuff in the setTarget function is setting up the variables needed to pull the curve into the right place.

The if statement is there to prevent the box continuing to follow the curve after it as reached the target.

const Pi = 3.141592;

var toMultiplyCosineBy;
var toMultiplyXBy;
var toAddToAllThat;

var xPositionWhenTargetWasSet;

var setTargetX;
var setTargetY;

//the current position of the box
var boxX;
var boxY;

function setTarget(targetX, targetY)
{
   xPositionWhenTargetWasSet = boxX;

   var differenceInY = targetY - boxY;
   toMultiplyCosineBy = differenceInY / -2;
  
   var differenceInX = targetX - boxX;
   toMultiplyXBy = Pi / differenceInX;

   toAddToAllThat = boxY - toMultiplyCosineBy;

   setTargetX = targetX;
   setTargetY = targetY;
}

function calledEachFrame()
{
   boxX = boxX + 1;
   if (boxX < setTargetX)
   {
      boxY = toMultiplyCosineBy * cos((boxX - xPositionWhenTargetWasSet) * toMultiplyXBy) + toAddToAllThat;
   }
   else
   {
      boxY = setTargetY;
   }
}


My instinct would be to do something iterative and more 'manual' - like maintaining a vertical velocity for the box and having it accelerate and decelerate depending on its position relative to the start and end of its move.  This way is much more mathsy and deliberate feeling, which is good stuff!

Edit Tested and workin'.  Only thing I noticed is that the setTarget function assumes that the target's X position is in the direction that the box is moving.
« Last Edit: March 02, 2010, 05:49:46 AM by Salt » Logged
JasonPickering
Level 10
*****



View Profile WWW
« Reply #14 on: March 02, 2010, 09:30:18 PM »

thanks Salt. the Sine curve is pretty complicated, and I tried your idea of controlling the acceleration and deceleration and thats working really well. so the current plan is to have a Guide object that travels ahead of you in randomized paths and populates the level with obstacles above and below it. this is working pretty good but its limiting me on the obstacles I can put in. right now I have just clouds and trees which slowly approach the player. i had ideas for other things like clouds that moved up and down, and other things, but not sure how to get them to work with the current system I have.
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic