Recent posts by Dealmaster13 on Kongregate

Subscribe to Recent posts by Dealmaster13 on Kongregate

avatar for Dealmaster13 Dealmaster13 641 posts
Flag Post

Topic: Game Programming / Google Code Jam 2013

Yeah, but for some reason I couldn’t deal with that equation in Java without error

 
avatar for Dealmaster13 Dealmaster13 641 posts
Flag Post

Topic: Game Programming / AS3 tutorials

If you’re talking about Main, it’s a mistake on their part

You can have a look at the finished files if you want

 
avatar for Dealmaster13 Dealmaster13 641 posts
Flag Post

Topic: Game Programming / About curly braces

Funnily enough, I use the first when programming in AS3, and the second when programming in Java, just to illustrate how insignificant the difference is

I prefer the first aesthetically, but many IDEs, e.g. Eclipse, are based around the second format, so sometimes it’s just best to stick with how the IDE wants to play ball to prevent the need to alter settings and/or constantly edit pre-formatted code

 
avatar for Dealmaster13 Dealmaster13 641 posts
Flag Post

Topic: Game Programming / RAM usage

Just note that I’m pretty sure those memory statistics also take into account any Flash running in the background, such as Youtube videos, adverts, etc.

 
avatar for Dealmaster13 Dealmaster13 641 posts
Flag Post

Topic: Game Programming / Google Code Jam 2013

I tried using BigInteger/BigDecimal post-event, but I needed to square root, and that caused problems for me

My solution would have otherwise been a four or so lines worth of mathematical equations – no loops involved whatsoever

 
avatar for Dealmaster13 Dealmaster13 641 posts
Flag Post

Topic: Game Programming / Google Code Jam 2013

They have three sub-rounds to ensure that at least one is likely to be at a reasonable time

Argh! Unbelievable!

Got frustrated with the pretty trivial bullseye problem, because I couldn’t simplify a bog-standard algebraic sum on paper in an (‘easy’) attempt to go straight for an efficient solution… :(!
Ended up solving the manage your energy problem after 2:28:41 and a hell of a lot of ridiculous debugging… yeah… just over 1 minute spare, and thus came a few hundred ranks short

By far the most disappointing code jam session I’ve taken part in over the past four or so years.
Then again, I was just a few seconds away from walking out with 0 points haha

Well, good thing the next rounds don’t actually start at 2:00am, like this one did; better luck next time

EDIT: Congrats on the fastest first problem solution by the way, jonathan

 
avatar for Dealmaster13 Dealmaster13 641 posts
Flag Post

Topic: Game Programming / Adjacent Grids [AS3]

Didn’t bother looking into the semantics of your code, but might you have meant to use continue instead of break?

 
avatar for Dealmaster13 Dealmaster13 641 posts
Flag Post

Topic: Game Programming / Google Code Jam 2013

Thanks a lot for the link

 
avatar for Dealmaster13 Dealmaster13 641 posts
Flag Post

Topic: Game Programming / Google Code Jam 2013

For fair and square, I figured you should just iterate through the square numbers (which I did), and so getting through 107 numbers (note also storing these – pre-computation) is obviously a breeze, but I still don’t have a clue as to how to solve the extra large, having already very briefly glanced at a few solutions out there; somehow you’ve got to pick out a mathematical property of possibly palindromes with squares that greatly reduces the sample space

 
avatar for Dealmaster13 Dealmaster13 641 posts
Flag Post

Topic: Game Programming / A* (Star) Pathfinding (AS3) - Example

Maybe try really messing up the grid, placing blocks and taking them away and see if you get any weird paths

 
avatar for Dealmaster13 Dealmaster13 641 posts
Flag Post

Topic: Game Programming / A* (Star) Pathfinding (AS3) - Example

Haha

Good work with the interface by the way

 
avatar for Dealmaster13 Dealmaster13 641 posts
Flag Post

Topic: Game Programming / A* (Star) Pathfinding (AS3) - Example

Not sure what’s going on here:

 
avatar for Dealmaster13 Dealmaster13 641 posts
Flag Post

Topic: Game Programming / Diagonal Speed Boost

Not 100% sure what you’re doing, but why don’t you separate the rendering from the logic ever so slightly by storing a floating point and integer representation of an object’s coordinates and render with the integer version?

 
avatar for Dealmaster13 Dealmaster13 641 posts
Flag Post

Topic: Game Programming / Any good AI(in strategy game) reading?

This is a reasonably good resource to use how you like: http://www.gamedev.net/forum/9-artificial-intelligence/

This is a pretty popular book, although the series is very expensive and one or more of the books I think are out of print: book

You might want to sift through this page: http://www.gamedev.net/topic/592473-recommended-ai-books-and-sites/

Best to start simple and focus on AI as a whole rather than for a specific genre and apply the concepts that you learn

 
avatar for Dealmaster13 Dealmaster13 641 posts
Flag Post

Topic: Game Programming / Platform shooter AI

The easiest way to learn, from first hand experience, is to put everything into practice yourself

It’s easy to forget why something is useful or when something should be used if you’ve never implemented the relevant features before

Starting from the basic principles of object oriented programming is definitely the way to go, in my opinion, but reading through documentation doesn’t sound like the most efficient way to go about things

 
avatar for Dealmaster13 Dealmaster13 641 posts
Flag Post

Topic: Game Programming / Platform shooter AI

The same question came to mind halfway through writing my post, but then I quickly realised that my most recent game had one AS file, no classes, hardly any functions and all of which took no parameters

There is a deceptive drawback to the expressive power that high-level languages offer – unless if you’re taught otherwise, you may consider your solution to be sufficient in terms of making use of the language’s capabilities

The alternative to using parameter-based functions is to use global variables, of course
While you’re probably just joking around, you should realise that there are many AS3 constructs that are unnecessary in most contexts, although obviously nice to have
Like I mentioned earlier, if there was no problem-solving or decision-making aspect to programming, then it would be a lot less interesting than it currently is

 
avatar for Dealmaster13 Dealmaster13 641 posts
Flag Post

Topic: Game Programming / Platform shooter AI

Yeah, they’re function parameters

You call a function, passing in the relevant arguments: in this case, startPoint and endPoint (local variables).
The function can then manipulate the local variables.

Like Java, AS3 is call-by-value in the sense that all parameters are passed as values rather than references.
All primitive types (e.g. int, Boolean) are handled as raw values while all non-primitive types (e.g. Array, MovieClip, Point) are handled as references , which means that by passing a variable point of type Point to a function as a parameter, you are actually passing a reference to the variable point rather than a copy of point ’s binary data.
In the case of a primitive type parameter, due to the call-by-value nature of AS3, changing the primitive type within the function will not affect the original variable outside of the function. In the case of a non-primitive type parameter, due to the fact that these variables are handled as references, the reference to the variable is the same within and outside the function, so a change to the variable within the function will be visible outside the function and remain intact after returning from the function.

The snippet of code you’ve quoted above is a constructor for Edge.

http://www.tutorialspoint.com/java/java_methods.htm
http://www.oracle.com/technetwork/java/prog-140388.html#fields

 
avatar for Dealmaster13 Dealmaster13 641 posts
Flag Post

Topic: Game Programming / Platform shooter AI

You don’t need underscores prepended to the x and y variables… think about why…

Might as well have defined the Point class as follows, but decided to be a little bit more conventional:


//package

class UselessClass { //don't extend anything as you don't need any other class' properties to define a UselessClass
  //declare your fields
  public var howAreYou:Number;
  public var helloImBob:Number;

  //define a constructor
  public function UselessClass(_482372:Number, ALPHA:Number) {
    howAreYou = _482372;
    helloImBob = ALPHA;
  }
}

var usefulPoint:UselessClass = new UselessClass(5, 10);

Perhaps you might want to Google what makes a valid variable name in AS2, and if you feel like it, compare what’s said for AS3, and hopefully you’ll be pleasantly surprised

It’s been a while since I’ve coded in AS2, and when I did, I wasn’t writing code like above, but you might be more surprised by the fact that I’m pretty sure the above is both valid and correct AS2 code and valid and correct AS3 code

It might be a good chance for you to reflect on having situations where you may want to define your own classes such as a Point or Edge class
Discover what you can achieve with classes

As a side note, being in Java mode, I was missing the function keyword from my methods, and translated all of the other accidental Java syntax to AS2

 
avatar for Dealmaster13 Dealmaster13 641 posts
Flag Post

Topic: Game Programming / Platform shooter AI

A Point class as we know it is a simple data structure, which at the very least contains two fields: numbers x and y

Define your Point class just as you would for any other class:


//package

class Point { //don't extend anything as you don't need any other class' properties to define a Point
  //declare your fields
  public var x:Number;
  public var y:Number;

  //define a constructor
  public function Point(x:Number, y:Number) {
    this.x = x;
    this.y = y;
  }
}

You can improve the implementation above further, in terms or security, functionality, or otherwise, should you wish.

For each boundary polygon node, of an object, at position (xi, yi), define a new Point: var point = new Point(xi, yi);
Perhaps store this in an array: var nodes:Array = new Array(); nodes.push(point);
Decide on your implementation strategy – perhaps each adjacent pair of nodes in nodes is an edge?
Perhaps create an edge class:


//package

//import Point

class Edge { //don't extend anything as you don't need any other class' properties to define an Edge
  //declare your fields
  public var startPoint:Point;
  public var endPoint:Point;

  //define a constructor
  public function Edge(startPoint:Point, endPoint:Point) {
    this.startPoint = startPoint;
    this.endPoint = endPoint;
  }

  //perhaps define an intersection function
  public function intersects(edge:Edge) : Boolean {
    //intersection algorithm
  }
}

var edges:Array = new Array(); edges.push(new Edge(nodes[i], nodes[i+1]));

It’s entirely up to you how you go about this.

If there was only one was of doing things while programming, it wouldn’t nearly be as entertaining as it is, and there wouldn’t be so much disparity between the capabilities of a ‘good’ and a ‘poor’ programmer.

 
avatar for Dealmaster13 Dealmaster13 641 posts
Flag Post

Topic: Game Programming / Platform shooter AI

If there’s no Point in AS2, then there is no issue with storing the x and y values separately.

Do you think you would be able to make your own Point class in AS2 if you had to? Half of the task is understanding how to approach the problem; then you have to put it into practice.

The MovieClip approach is something I came up with whilst thinking about solutions to a problem. If you want to go down that approach, then try to think about how to solve the problem using the tools you have available to you.

 
avatar for Dealmaster13 Dealmaster13 641 posts
Flag Post

Topic: Game Programming / Platform shooter AI

One option is to hardcode a list of Point variables for each object (storing this in the relevant class as a static variable )

Another option is to make use of the functionality that the Flash IDE offers: create a node symbol (no need to export to ActionScript), graphically place the nodes around each MovieClip, give them instance names, and in code iterate through the nodes to work out their relative locations (see here )

The first solution is purely mathematical and is more efficient as it only stores information for the class rather than for each object of the class (as well as keeping things non-graphical)

An alternative solution which is very complex is to analyse the graphical image of the object itself and use a tolerance parameter to evaluate how to divide the shape into nodes

I’m sure others can come up with yet some more solutions

 
avatar for Dealmaster13 Dealmaster13 641 posts
Flag Post

Topic: Game Programming / Platform shooter AI

The idea is to try to ditch bounding boxes (rectangles) in favour of bounding polygons.

A polygon is defined by a series of lines, which is better described as an ordered list of connected points.

Take each edge of the polygon and perform a line intersection check between the line of sight and the polygon edge. If they intersect, then the polygon ‘blocks’ the line of sight.
Take the case where the bounding polygon (e.g. rectangle) may not exactly match the outline of the object in question – perform line clipping against the bounding area and perform a series of hit test points between the (pixel) points on the line and the (irregular) object in question.

 
avatar for Dealmaster13 Dealmaster13 641 posts
Flag Post

Topic: Game Programming / Platform shooter AI

@dragon
Line clipping: http://en.wikipedia.org/wiki/Line_clipping

Where did I mention that you should not use an “array of bounding lines” for the bounding shape?

Perhaps you’re confused about my suggestion in the case that the object is an irregular shape and not representable as a simple polygon

 
avatar for Dealmaster13 Dealmaster13 641 posts
Flag Post

Topic: Game Programming / Platform shooter AI

Depending on the size of your map, you’ll probably also want to look into quadtrees to help determine which objects you need to perform line of sight against.

For non-square and non-circle objects you’ll probably also want to think about constructing a bounding polygon for them or alternatively a bounding box and then if you want to do things accurately and mathematically (not graphics-graphics-hit-detection) you could perform line clipping between the line of sight and and bounding shape (which is hopefully not too large) and perform a hit test point between each pixel in the line (using a line drawing algorithm) and the object with its (alpha) flag set

 
avatar for Dealmaster13 Dealmaster13 641 posts
Flag Post

Topic: Game Programming / Java applets

It’s funny we should be mentioning all this as Chrome has also had crashing issues on iOS during this past month

Luckily I noticed the 1.5 star rating before choosing to update or not