Recent posts by BadEgg on Kongregate

Flag Post

Topic: Game Programming / GiTD #35 Ten Seconds

Ok, it’s nowhere near ready yet and is currently annoying as hell, but here’s what I’ve managed to do so far. http://www.swfcabin.com/open/1377715933

 
Flag Post

Topic: Game Programming / GiTD #35 Ten Seconds

Gahhh!! Only 2 hours left to go. http://www.ludumdare.com/compo/ld27-theme-voting-round-5-of-5/

I don’t want to stay up until 2am but I also just really want to know what the sodding theme is. I’ve got a girlfriend-free weekend and a bank-holiday monday so feel like I’ll be able to make a pretty decent effort for this one.

 
Flag Post

Topic: Game Programming / I'd like to commission a game, where do I begin?

It’d be good if you could post a link to your company’s website, there are so many 13 year olds who come onto the forums saying that they have an amazing idea for the next big MMORPG and want a team of programmers and artists to do the work building their idea while they sit back and busy themselves being the ‘ideas man’.

Also, if you’re commissioning people to create this for you then what’s in it for them other than recognition? Are you going to pay them a wage while they’re working on the project or would they have to wait for the game to be released and start making money before they get a share of the profits?

 
Flag Post

Topic: Game Programming / Need help with tower defense shoot logic

Originally posted by ehaugw:

Did anyone try my neat formula before doing the while loops?

The problem I have with your formula is that you give no indication of how you calculate the interception point. I’m guessing the interception point is where you’re expecting the bullet to meet the enemy, and that’s what pretty much all of my code is trying to find out. Once I’ve found that point, all that’s left to do is just:

return Math.atan2(iPos.y - bulletPos.y, iPos.x - bulletPos.x);

Which is about as simple as it gets really.

ps. the while loop will very rapidly converge on the interception point so in practice you’re probably only looking at about 3-5 iterations which is pretty good I think considering that there’s really not much heavy lifting going on inside the loop.

 
Flag Post

Topic: Game Programming / Deeper Topic (Part 0): Class Discussion and Review

Actually qwerber, using my method each system gets delivered only the entities which have the correct components needed for it to be operated on…that’s what my stores do that I mentioned previously. Also, in Entity Systems, the systems run sequentially. So the velocity system will run through all of its entities, then the collision system will run through all of its entities, then the render system will run through all of its entities etc.

 
Flag Post

Topic: Game Programming / Need help with tower defense shoot logic

This is a code version of my suggestion (not tested yet):

function calcPredictiveShotAngle(targetPos:Point, targetVel:Point, bulletPos:Point, bulletVel:Number, errorMargin:Number = 2):Number{
     //bulletPos is the position of the bullet when it is first instanciated
     //errorMargin is how close the target needs to be to the edge of the circle before it is considered to be on the edge of the circle
     
     //Set t with an initial value so the starting position of the target is on the edge of the bullet's circle
     var t:Number = Math.sqrt(Math.pow(targetPos.x - bulletPos.x, 2) + Math.pow(targetPos.y - bulletPos.y, 2)) / bulletVel;
     
     while{
          //The position of the target at time t
          var iPos:Point = new Point(targetPos.x + (t * targetVel.x), targetPos.y + (t * targetVel.y));
          
          var radius:Number = t * bulletVel;
          
          //If the target is close enough to the edge of the circle at time t then break the loop
          if(Math.pow(iPos.x - bulletPos.x, 2) + Math.pow(iPos.y - bulletPos.y, 2) - (radius * radius) <= errorMargin * errorMargin){
               break;
          }
          
          //Update t so that the circle radius touches the point of the previously found target position
          t = Math.sqrt(Math.pow(iPos.x - bulletPos.x, 2) + Math.pow(iPos.y - bulletPos.y, 2)) / bulletVel;
     }
     
     return Math.atan2(iPos.y - bulletPos.y, iPos.x - bulletPos.x);
}

@Moocowsgomoo, I think we all know that such a task is impossible. I think that pretty much all the suggestions so far have made the assumption that the target continues to move with relatively unchanged velocity throughout the period of the bullet heading towards it.

 
Flag Post

Topic: Game Programming / Need help with tower defense shoot logic

All these solutions seem rather complex.

At the time the bullet is fired, we’ve got the position and velocity of the target enemy, and we’re assuming that the enemy will carry on travelling in that direction, so the enemy’s position can be represented (in psuedo-code) as:

position = startPosition + (velocity * t)

Where startPosition is the point representing where the enemy is at the time the bullet is fired, t is time (measured in number of game updates since the firing of the bullet) and position is the predicted position of the enemy at time t.

Since we don’t yet know which angle we’re going to be firing the bullet in, the bullet’s position can be represented as a circle with an ever-expanding radius:

focus = turrent.position
radius = t * bulletVelocity

The edge of this circle represents the entire set of possible positions the bullet could be at for time t.

At this point you’ve now essentially parametrised the problem, so now you just need to create a loop which tweaks the value of t until the enemy’s position is a point on edge of the circle and use Math.atan2 to get the direction the bullet will need to travel in to head toward that point.

 
Flag Post

Topic: Game Programming / Deeper Topic (Part 0): Class Discussion and Review

Originally posted by qwerberberber:

I don’t think you should ever be looping through a collection of entities.

Ummm…that’s pretty much all a system does. It goes through a set of entities which have the required components and applies some action to them. Out of curiosity…why do you think it’s such a bad idea?

 
Flag Post

Topic: Game Programming / How can I get my player's rotation to point to the ground's angle? [As2]

I’m not sure how you’d implement this in AS2 but my way of doing it would be to have a small rectangle used for collision detection positioned bottom-center of the player, if a collision occurs on this rect then you know that the player is touching the ground so you need to update the player’s angle. To do this you’d need to find 2 points within that rect where the ground meets the air, from those 2 points you can get a pretty decent approximation of what the angle of the ground is.

 
Flag Post

Topic: Game Programming / Deeper Topic (Part 0): Class Discussion and Review

@Elyzius, thanks for those links, I’d been trawling the internet trying to find good stuff on the subject but those 2 slipped my net. It’s quite a nice idea of doing the bitwise checks for entities although I can imagine being limited to 32 components throughout the entire game could become quite restrictive if you worked on anything of a fairly large scale.

My main concern when creating my system was that it seemed very expensive to create a list of entities on the fly for each system that runs so I created my ‘stores’ which hold their own little arrays of which components they consider good and bad. Then each time a component is added to an entity, all the stores check if that entity has all the good components and none of the bad components, if so then they add that entity to their list. Each system then takes the list of entities from a particular store and loops through them.

Also, pretty much every article/tutorial that I’ve seen on the subject of Entity Systems creates a class ‘Component’ which all components are based on. Is anyone able to explain what benefit that you’d get from that?

 
Flag Post

Topic: Game Programming / Deeper Topic (Part 0): Class Discussion and Review

@Elzyius, I’m guessing that you too read t-machine (http://t-machine.org/index.php/2007/09/03/entity-systems-are-the-future-of-mmog-development-part-1/)

I’ve been working on my own ES based on this with a couple of little nifty features of my own thrown in for good measure.

When I was going through Drakim’s post I kept thinking that it was a really nice idea but in reality it just didn’t seem particularly manageable once I actually started trying to create anything. Once I started reading about the complete separation of data & logic and understanding the implications of that, I realised how much better a way of working it is. It’s taken me a while and a few re-designs of some of my core systems / components but I’m now getting to the point with my ES that things almost feel like plug-and-play when I’m adding features.

 
Flag Post

Topic: Game Programming / GiTD #34 Has begun, the theme is "Creation/destruction"

I don’t think I’ll be able to complete my entry, it’s a combination of me being a bit too ambitious and my entity system not being quite up to the job for this yet. It’s a shame because I really like this contest and the pressure it puts upon you to actually get something finished, I’ll definitely have something to submit for next month’s contest.

 
Flag Post

Topic: Game Programming / GiTD #34 Has begun, the theme is "Creation/destruction"

Thought it was time for me to upload what I’ve done so far: http://www.swfcabin.com/open/1373812848

I found a worms map off the net for me to do my testing on, so far seems to be coming along pretty well I think.

Use arrows or WASD to move & the mouse to shoot.

I’ve also added a prototype enemy although at the moment it seems to be acting more like an overly affectionate dog…more work needed on that. Any feedback welcome.

 
Flag Post

Topic: Game Programming / GiTD #34 Has begun, the theme is "Creation/destruction"

Originally posted by feartehstickman:
but explosion effects are more of a polishing thing and not too important for a GiTD unless you have the time.
Time for me to think of an idea :/

Yeah, my thoughts exactly, make sure you’ve got 4 wheels and an engine before you start worrying about the seat warmers.

 
Flag Post

Topic: Game Programming / GiTD #34 Has begun, the theme is "Creation/destruction"

Thanks for the link feartehstickman, you posted that just as I was about to start looking for how to actually explode the terrain. The destructable terrain in that tutorial is really impressive, I’m not sure that I’ll implement particles in the explosions though as I’m hoping to have proper swarms of enemies coming for the player and don’t want to make things too CPU intensive!

 
Flag Post

Topic: Game Programming / GiTD #34 Has begun, the theme is "Creation/destruction"

I’m trying to build a platformer with worms-esque destructable environments. This is the first time I’ve ever had to use pixel-perfect collision detection so spent most of yesterday trying to get that working convincingly. Looking pretty good now so next it’s time to add some jumping (currently my character is levitating off the ground whenever I press up) & then try to bring in the weapons to start exploding some graphics!

 
Flag Post

Topic: Game Programming / GiTD #34 Has begun, the theme is "Creation/destruction"

Definitely going to try and make something for this, mine is probably going to end up focussing way more on the destruction than creation though :P

 
Flag Post

Topic: Game Programming / GiTD Rule Change Voting! Voting ends 7/7/13 6PM GMT

Originally posted by I_love_you_lots:

Just an FYI, I won’t be participating in the next GiTD because I dropped a plate of pizza on my computer and now it doesn’t work.

As excuses go, that’s up there with the best of them

 
Flag Post

Topic: Game Programming / As2: ifchange command?

@I_love_you_lots, that’s not quite what the OP was asking since that does a continuous spam of messages whenever the movieclip is touching the ground. For it to only trace when the state changes from true to false / false to true I’d use a setter:

private var _touchingGround:Boolean = false;

public function set touchingGround(touching:Boolean):void{
     if(touching != _touchingGround){
          trace(touching);
     }
     _touchingGround = touching;
}

You may need to do some converting to get this to work in AS2 since I’m only familiar with AS3 but the principles are the same.

 
Flag Post

Topic: Game Programming / my first flash game for pc

Originally posted by GameBuilder15:

Kong should make a forum for threads like this.

Isn’t that called Collaborations?

 
Flag Post

Topic: Game Programming / What does this mean? (Event subclasses)

I personally disagree with the author on this point, it is not an absolute necessity, just best practice. I used to create loads of custom events in my games and have not once overridden the clone() or toString() methods.

 
Flag Post

Topic: Game Programming / GiTD Rule Change Voting! Voting ends 7/7/13 6PM GMT

I vote G, this seems to be the only option which won’t restrict the voting audience (You could argue that option D wouldn’t either but I’m pretty sure that a lot of people don’t want to write a review to every single game in the contest in order for their vote to count).

Since there seems to quite often be disputes over the tallying up of the scores, I also think that when the voting period ends, someone should take screen-caps of the thread so that confusion can be avoided if people do change their vote afterwards

 
Flag Post

Topic: Game Programming / What is an event object?

Events in flash are a bit confusing because of the way that they move through the display list, but a good example to help you understand how they work is the MouseEvent. Suppose I have my character (I’ll call him Bob) added to the stage and that I click on his face. The stage detects that a click occured and creates a new mouseevent object with the stage position where the click occured. This new mouseevent now looks through each of the stage’s children to find that the click happened on Bob so it sets Bob as it’s target.

It then looks through all of Bob’s children (face, torso, arm1, arm2, leg1, leg2) to find that the click happened on the face, so mouseevent.target gets set as face.

It then looks through all of Bob’s face’s children (eye1, eye2, nose, mouth) but the click didn’t happen on any of those so mouseevent.target remains as face. All of what I’ve described above is known as the capturing phase and generally happens behind the scenes. The purpose of this is to find where within the program the event originated from.

Once the event has reached its target, it then starts the Bubbling phase which is where it goes back up through the display object until it reaches the stage again by using each object’s parent property. At each object it shouts out “Hey, someone just clicked on a child of yours!”. Each time this occurs, the display object in question then looks through its list of EventListeners to see if any of them are interested in clicks, if it finds one then the function held in that listener gets called with the event object passed as a parameter so that it has all the information it needs in order to process the event correctly.

 
Flag Post

Topic: Game Programming / Proposing Rule Changes in the GitD?

I think that I_love_you_lots has the right idea with the Operator, Member, Spectator model.

As for .exe files, I think everyone here is savvy enough to understand that they open an exe file from an unknown source at their own risk. Therefore I don’t see any need to ban them but just make it clear to people submitting in this format that it is unlikely they will win due to the limited audience (I chose not to play the exe game from the last GiTD for this reason).

Also, modifications after the deadline is something that is not easy to police because unless people play the entries numerous times throughout the voting period, they’ll have no idea how much the games may have changed. So maybe it’s best to just take an honesty box policy on this matter, I wouldn’t make changes to my game after the deadline but other people might and that really doesn’t bother me. If really big changes are noticed in a game then words can be had, but no point getting wound up about little tweeks.

Finally, the prize. From what I’ve seen of previous contests, having a prize does seem to improve the quantity (and quality) of entries so no sense in getting rid of it. I don’t really use kreds so am not motivated by the possibility of some virtual gold in my virtual pocket but I can understand that it may seem more enticing to others. Prizes encourage competition, which in turn encourages greater creativity among entrants, I think that suffering underhanded tactics from the occasional unscrupulous entrant is a price that’s worth paying for that tbh.

 
Flag Post

Topic: Game Programming / GiTD [#33] Votes recounted, congratulations Zoib!

1. Feffers: Dungeon Seekers
2. Shalmezad: .explore

I would have liked to play No given name but it ran just a little bit slower than a snail’s pace on my computer.

Delver looked promising but I also encountered problems with this running slow (which is weird considering my computer really isn’t that bad) and after fighting my first enemy I then managed to get myself stuck in a wall so decided I’d had enough.