Jump to content

  • Log In with Google      Sign In   
  • Create Account


thok

Member Since 23 Dec 2011
Offline Last Active Today, 09:17 AM

#5162984 Map in spacegame? How to avoid all-open travel and "boring" worlds?

Posted by thok on 26 June 2014 - 04:36 AM

Another alternative would be to allow FTL (faster-than-light) travel in particularly open areas of space where there really is nothing, or at least nothing significant (so you don't have to suffer the boredom of waiting, like the boats in classic EverQuest). When you approach objects with a significant mass/gravity well (asteroids, planets, suns, etc.), FTL is travel not possible--and if you get close enough, you'll get pulled out of hyperspace.

 

This could really make boring space travel a lot more interesting. For example: Let's say you have a map with known and charted planets/objects. You want to cross a large stretch between two systems which appears on your map to just be empty space. You make the FTL jump, but halfway through you get pulled out of hyperspace by the gravity well of a massive planetoid/star/etc. which wasn't on the charts. So then you can explore it, etc....




#5162019 Noob question on hashmaps

Posted by thok on 22 June 2014 - 02:12 AM

If you want to have the player object in the hashmap as well, and the hashmap is typed, the player needs to have the same interface as the other objects. That means, for example, that all of the objects could inherit from the same superclass, provided that there are enough similarities for this to make sense, of course. Otherwise, they could just explicitly implement the same interface. Then you should type the hashmap with the superclass or interface.

 

Make sense?




#5120040 Game design with Collision Detection

Posted by thok on 30 December 2013 - 10:34 AM

One way you can implement this is for your collision code to have direct control over the state of the sprites, as you've already described. With this design, however, you'll find that things are not well encapsulated. Your collision code check for collisions, decide how to respond to the them, and then act out those responses as a side effect. I think it's better for your collision to be more "functional" and stateless, meaning that it takes as input some objects which potentially collide, find collisions, calculate a suggested response to the collisions, and outputs those suggestions. These suggestions can then be consumed by another piece of code which doesn't have to do any calculation, it simply acts. In this way, your game has smaller, simpler components which are easier to test, debug, and reuse.




#5087284 Programmer's "writer's block" and getting bogged down

Posted by thok on 19 August 2013 - 06:40 AM

So I've started working on a game, essentially a tile-based RTS-type thing using Java and LWJGL, and I'm having a pretty big issue: I can't get anything done.

 

For starter's, I can't figure out where I wanna start. "Do I want to start with the display/graphics system?" "Maybe the logic?" "Or how about the input and event systems?" "Maybe I should go back to the drawing board and diagram everything out." "Diagramming takes too long, just a sketch." "Forget it, I'll just jump straight in."

 

Then there's the matter of how I want to do things. "I want to use MVC architecture." "I can't do that, that's not perfectly in line with MCV standards." "I've heard good things about component-entity system architecture, maybe I should try that." "Wait, how do I lay this all out?" "How do I wanna script this? I like Javascript, is Rhino any good?"

 

And then there's the infamous, "Okay, new idea, better scrap the whole thing and start again."

 

Basically, I'm finding my head being a clusterfunk of ideas and can't seem to find a good place to start without getting bogged down. Does anyone have any advice for dealing with this?

It sounds like a typical case of analysis paralysis. The solution? Implement something simple and extend it later. So you're wondering whether to work on the graphics, logic (I'm assuming you mean game update logic), or input/event handling? I say, work on all of it. Build small pieces of each and keep iterating.

 

I think fir is right: start with your game loop and draw some basic things (the world plus a character in the world). Then implement a basic input handler to move the character. Start with basic keyboard input (arrow keys) and then extend it to use mouse input. Try to add something new every day you work on it, even if it's a small feature.

 

It is good to study design patterns, but don't start with the pattern--this is the wrong approach to building things. Instead, just start building the thing and make abstractions when it seems appropriate. Patterns will emerge over time with refactoring.

 

It's just like Lego; just keep building and don't worry about change. Be prepared to scrap large chunks of what you have built and replace it with something better/stronger/nicer looking.




#5083895 2D Map - Data Structure (Not really Java specific)

Posted by thok on 07 August 2013 - 10:18 AM


I think the last "worry" about my object structure is that I will be putting multiple types in the same array.. including players.
Ex:
Object[0] = Wall at 0,0
Object[1] = Wall at 10,0
Object[2] = Player at 10,10
 
I'm sure I can handle this from a code perspective, but you mentioned above avoiding this style of data structure. The alternative is to have a unique structure for every single object type. Only things I can think of are Objects (Walls, etc) and Players. Granted, both can fit into the same category to some degree but they will need their own classes.
 
Having a unique structure for Objects and Players would get messy.. and also destroy the whole overlapping draw system. In order to have them draw correctly, I would need to add a THIRD structure, let's call it Draw. Draw would contain the "draw order" and would simply point to either an Object or a Player.. but now we're really just back to having everything, aren't we? A little different since the Draw would only contain a pointer and not the object itself but .. now we're up to 3 structures instead of 1.
 
I think that's it..

 

There's another way.

1) Keep distinct types of objects in separate data structures (ArrayLists, for example). The most derived classes of the objects in each don't need to be the same, they just need have a common enough interface to justify putting them in the same array.

2) When it's time to draw, search for the items which you need to draw. Make it a brute-force linear search for now, and optimize it later with a smarter search. Once you have this filtered list (let's say, a total of 1000 objects down to 20), sort them by their Z components and render in the correct order. It could look something like this. My Java is a little rusty, so bear with me:

// This is basically what your classes can look like.
public interface Drawable {
	public void draw();
}

public abstract class Entity implements Drawable {

	public double x, y, z;
    
}

// Note I call it `GameObject`, not Object, so as to not be confused
// with java's built-in Object class.
public class GameObject extends Entity implements Drawable{

	public void draw() {
		// TODO: implement me
	}
}

public class Player extends Entity {

	public void draw() {
		// TODO: implement me
	}
}

Then you need to keep your various game objects somewhere:

// TODO: populate these
List<GameObject> objects = new ArrayList<GameObject>();
List<Player> players = new ArrayList<Player>();

Then you can implement a filter to search for the only the objects in view, given min/max x/y of the current view.

	public List<Entity> static filter(double minX, double maxX, double minY, double maxY, List<Entity>... lists) {
		List<Entity> filtered = new ArrayList<Entity>();
		
		for (List<Entity> list : lists) {
			for (Entity e : list) {
				if (e.x >= minX && e.x <= maxX && e.y >= minY && e.y <= maxY) {
					filtered.add(e);
				}
			}
		}
		return filtered;
	}

You can call it like this:

List<Entity> filteredStuff = filter(0, 480, 0, 640, objects, players);
// Edit -- then you can render:
for (Entity e: filteredStuff) {
  e.draw();
}

Then you can sort them by having entity implement `Comparable`, and using `Collections.sort`. See http://docs.oracle.com/javase/7/docs/api/java/lang/Comparable.html and http://docs.oracle.com/javase/7/docs/api/java/util/Collections.html#sort(java.util.List).

 

Notice that, since your `filter` is a separate, self-contained function/method, you can easily swap it out with alternate implementations, when it comes time to optimize. The inputs and the outputs are the same, but the algorithm can change. Make sense?




#5083860 2D Map - Data Structure (Not really Java specific)

Posted by thok on 07 August 2013 - 07:36 AM


This had crossed my mind before although I didn't think of it again until you mentioned it. Method 2 makes it easy to find all objects in a given map. But if I wanted to do something like .. find all objects from 2,2 to 3,3, I would need to do a brute force search through my object structure to find them all (although if they were sorted, I could easily stop once I reached 3,4). Using method 3 helps alleviate this. I agree that it is messy though, but I feel like the solution still *has* to be to index the objects by location.

 

If I understand your design correctly, your game objects can be positioned anywhere, right? "not just locked to the grid", as you said. So that means that any given point in time, your objects can be literally anywhere. So it doesn't make sense to assign them to grid cells, and then move them to another grid cell when they move far enough.

 

And yes, using this method, if you wanted to find all objects in a given area by looping over each object and checking for intersection is brute force. It's inefficient. But it's also simple and works just fine for small number of objects. When this becomes a bottleneck, you can replace it with some better based on, for example, a quadtree. For now, just make it simple and make it work. Worry about optimizing later. (See below.)

 


It's funny.. I've been working with a proprietary programming language for medical software for the past 2 years. It was designed around being simple and building interfaces for data entry. Being the person I am, I tweaked it and made a 2D game with it. The problem is, the language is never compiled, only interpreted .. which gives it a TON of overhead. Re-drawing the screen is a great way to make a slow game.
 
I have a hard time getting into the mindset of "This is a modern language - it was MADE to do this kind of stuff. It can redraw the screen more than once a second and you wont see a problem". So I keep going at this trying to be careful with what I'm doing. I guess it's not really a BAD thing (optimizing the program for performance), but it can lead me to try some strange solutions and make some messy code.
 
That being said, yes.. I think every time an object changes, I will need to
1) Sort the list of objects
2) Re-draw them
 
I even cringe writing that because I know in this proprietary language that would not go over well.

 

You're using Java on modern hardware right? You can draw 60 frames per second, no problem. So put the limitations of this proprietary language out of your mind, they shouldn't concern you.

 

 

I see that you're concerned about performance, and that's okay, but I think you're getting way ahead of yourself. Give this a read: http://c2.com/cgi/wiki?RulesOfOptimization

 

To summarize the rules of optimization:

1) Don't.

2) Don't yet.

3) Profile before you optimize.

 

So if optimizing early is making you write bad code, stop doing it! =P

 

Other advice:

1) First make it work

2) Then make it elegant

3) THEN make it fast

 

I hope that helps.




#5083187 Is Python underestimated with what it can do?

Posted by thok on 05 August 2013 - 04:52 AM


You seem to be missing the fact that Python is already a hugely popular and successful programming language:
EVE online (among other games), is written largely in Python.
A good chunk of Google's infrastructure is written in Python.
Python is the scripting language of choice for content creation packages like Maya.
TIOBE ranks Python as the world's 8th most popular programming language.
And so on...

 

A few more specific examples of "popular" applications that I know of:

 

- OpenStack

- Blender (for scripting, not the application itself)

- The backend for yelp.com




#5083186 Is Python underestimated with what it can do?

Posted by thok on 05 August 2013 - 04:46 AM

All languages seem to get degraded, lets just call it language insecurity or e-religion, I mean if you compare the language comparison threads with theological comparisons you would actually be quite amused on how similar they are, which would probably explain why some people are obsessed with defending their language of choice while criticising others and religiously sticking with it lol.

 

The important thing is that you are learning / increasing your knowledge, it doesn't matter if its C, Python, C++, C# or even assembly, the more you practice the better you get (providing ofc you are actively learning and not just assuming stuff in other words making mistakes) and the closer you will get to your compiler God.

Totally agree with this. I think that instead of discussing "what makes language X is better than language Y, Z, etc.", I think it's more worthwhile to discuss "what makes language X good", period. Otherwise, it's just religion, complete with witch hunts and stoning. =P




#5083185 Is Python underestimated with what it can do?

Posted by thok on 05 August 2013 - 04:42 AM

Some general comments about "speed". Disclaimer: I code (mostly) in Python as a full time job.

 

First of all, performance isn't just about language choice, but also algorithm choice. An inefficient program written in a "fast" language is still inefficient. So I don't think it makes sense to just label a language as "slow". As others in the thread have said already, sometimes just "fast enough" is sufficient.

 

Second, you have to take into account speed of _development time_. I realize that this is more of an economic measure, and that most everyone in the thread so far has been focused on speed of _performance_, but do not underestimate the value of this. If the need for development speed is greater than the need for sheer performance, a higher-level language, if it is just "fast enough", is a good choice.

 

Third, and this is a comment specifically about Python, many of the standard and third-party libraries available have parts of them written in C, thus they can be quite performant. This is a really nice feature in my opinion. The combination of high-level interfaces and the option to write extensions in C to address your worst computation bottlenecks is a pretty good combination and makes Python a good choice for a wide variety of applications.




#5083182 Is Python underestimated with what it can do?

Posted by thok on 05 August 2013 - 04:21 AM


I think it's hard to work with on projects of scale.

 

I agree with most of what you've said, except for this statement. Although I don't know understand exactly what you mean by "projects of scale", I'm going to guess that you mean "large projects". Feel free to correct me if that is not what you meant. If it is what you meant, this is simply not true. OpenStack, for example, is written in Python: http://www.openstack.org/. I would consider this to be a large project, anyway.

 

As a side note: Python is great for scripts, one-off tools, and quick-and-dirty prototypes, but anyone who says that's the _only_ thing that it's good for has probably never written a significant application with it. (Source: In my day job I develop on an open-source seismic hazard assessment engine, which can run regional and global scale calculations and is entirely written in Python. See http://openquake.org/.)




#5070848 Developing a cloud service/server for your app?

Posted by thok on 18 June 2013 - 08:11 AM

I just want to chime in here quickly and point out something very important: If you're stil in the process of learning, do not concern yourself with Amazon EC2 or "scaling". First you need to make things work. Trying to wrap your head around concepts like elastic cloud computing, scaling, and optimization are just noise to a beginner.

 

Scaling problems will arise if and when you have enough users. When that happens, you'll need to figure out the bottlenecks. At this early stage, you should resist the temptation to guess how your application needs to scale and just focus on building it.

To clarify, cloud hosting providers are a good option for hosting static servers, as well as dynamic scaling (as dmatter mentioned). My point is, try not to get lost in a sea of buzzwords. Focus instead primarily on just making your app work.




#5070846 Developing a cloud service/server for your app?

Posted by thok on 18 June 2013 - 08:04 AM

I just want to chime in here quickly and point out something very important: If you're stil in the process of learning, do not concern yourself with Amazon EC2 or "scaling". First you need to make things work. Trying to wrap your head around concepts like elastic cloud computing, scaling, and optimization are just noise to a beginner.

 

Scaling problems will arise if and when you have enough users. When that happens, you'll need to figure out the bottlenecks. At this early stage, you should resist the temptation to guess how your application needs to scale and just focus on building it.




#5063838 Online multiplayer Game programming

Posted by thok on 22 May 2013 - 07:43 AM

Hi people ! I have a game making project in my college, and I wanted a little help about how to go on about it. So let me first describe the project.
I have made a box filling game using python and pygame, so i know how to make UI, and the game programming. Apart from it, I know C language. I don't know JAVA and other stuff as yet, but if needed i can try that.


Phase 1: Make a GUI game, LUDO in which, 2 or 4 people can play against each other, through net login. If possible, do something so that these players can play this game through their browser, like online games are done. I saw one of my classmates implemented a version where the game would ask the ip of the computer to play against, and then these two people can play together online, but this idiot won't tell me how she did it.

If you want the game to run in the browser, Python/pygame aren't going to work. Python doesn't run in the browser.

You're better off with HTML5/JavaScript.

I posted some links in the following thread that will help you get started: http://www.gamedev.net/topic/643107-new-to-coding-strategy-game/#entry5062232

Phase 2: Add another mode to the game, to play against computer. If chosen to play against the computer, the game should behave as an artificially intelligent player to play against a human.

I need help regarding this. First of all, as yet, i have decided to use python and pygame for it. But i really don't have any idea whether it's a good choice or not, how i'm going to implement these things, etc. Please suggest an approach to complete the game. Eg:- You should use this "blah blah" language, because it has "blah blah" feature, which will help you. Then you can implement it online using "blah blah" thing. also this language will make it easier for AI programming... etc. I hope you get the idea what i want to really ask. Please help.

See the link I posted above; that will give you a good idea of the technology you'll need to learn to implement this game.


#5062232 New to Coding - Strategy Game

Posted by thok on 16 May 2013 - 03:23 AM

Hello! Let me begin by saying that I am a complete novice when it comes to coding. I have a good handle on symbolic logic, but that seems to only be tangentially related to actual coding. However, I am eager to learn as I have, due to my upcoming three month sabbatical, been elected by my friends to learn how to code a strategy game that we've been working on for a few months. The main question that I have is this, what sort of language should I set myself to learn in order to successfully code this game?

 

Onto what I understand are the essentials. 

 

First of all, we want this to be a strictly online game played in browser. Some of us have tablets as our main computing devices, others have Macs, others Windows, etc. We figured that a browser-based game would off the greatest accessibility.

 

Second, to go along with the online theme, this will be strictly humans vs. humans; no AI teams will be included. What AI there will be will follow very simple rules involving movement only.

 

Third, the game is fairly similar to a more advanced Masters of Orion. At the moment, we're playing it via Dropbox utilizing a hex-based board. It will be more advanced in that technology will progress in a different manner and units are more customizable.

 

So, any ideas about what language I should look into using? Do you need more information?

As others said, learn HTML5/JavaScript.

- For graphics, have a look at `canvas`: https://developer.mozilla.org/en-US/docs/HTML/Canvas

- For sound, have a look at `audio`: https://developer.mozilla.org/en-US/docs/HTML/Using_HTML5_audio_and_video

- For the multiplayer aspect, you'll probably need to learn about WebSockets: https://developer.mozilla.org/en/docs/WebSockets

- For an example of a multiplayer browser game, have a look at "BrowserQuest": https://hacks.mozilla.org/2012/03/browserquest/, http://http://browserquest.mozilla.org/

  - BrowserQuest uses all of the above technology.

- With all of that, you can code the game yourself. You may also be able to build off of existing game engines/libs. Here's a list of JavaScript game engines: https://gist.github.com/bebraw/768272

 

I'm giving you a bunch of Mozilla links, but all of this stuff will work in most browsers. In fact, I've personally found `canvas` to perform slightly better in Chrome than in Firefox.

 

I think 3 months is ambitious if you're new to coding, but you should at least be able to turn out some sort of prototype. It will be a good learning experience. Be prepared to throws your prototype away and start again. Write as much code as you can, and don't worry if the code you write is crap. That's how you will learn.

 

Hope that helps.




#5061789 2d Platformer Gravity - constant or conditional!?

Posted by thok on 14 May 2013 - 08:34 AM

It depends on what you want exactly. Personally, I would go with the first approach you described (gravity constantly pulls, objects intersect, and collision response removes the intersection). This is relatively simple.

 

If you're just trying to make a basic platformer, I wouldn't try to emulate the Sonic physics. Sonice is nothing like most other platform games. Keep it simple.






PARTNERS