• Create Account

Banner advertising on our site currently available from just \$5!

# SnakeM120

Member Since 19 May 2010
Offline Last Active Nov 27 2014 05:48 AM

### In Topic: Trying to add features to this game (HTML5/Javascript)

14 April 2014 - 05:34 AM

If you want to make a bigger level, you could use dynamic arrays.  (It seems that all arrays in JavaScript are dynamic.)  so basically:

```var sizeX = 100, sizeY = 100;

var map = new array(sizeX);
for (int i = 0; i < sizeX; i++) {
map[i] = new array(sizeY);
for (int j = 0; j < sizeY; j++) {
map[i][j] = 0;
}
}```

Would make a map 100x100 in size, and you access the values of the map this way: map[x][y].  All the values are initially set to 0.

Then I would perhaps make an array for the tiles:

var tiles = array();

tiles[0] = (Some reference to the image tile, attributes, etc that you need, 0 being 'nothing', 1 being 'grass', 2 being flowers, etc.)

Point is to make a list so that each value in the map array directly maps to the index of the tile table.  Example: if map[10][10] returns '4', its tile is retrieved using tile[4].

Just to flesh out my immediate idea.

For your movement, you could have a position x, and y for your character.  You also have values for the visible width and height of the visible position of the screen in number of visible tiles, and the top left corner position of this rectangle in the map.

Example:

You have a map sized 100x100.  You are positioned at 30x60.  The visible width and height is 21 tiles in each dimension, making you see 10 tiles ahead in every direction, not counting the spot you are on.  This makes all my coordinates inclusive start and end, meaning that a range from 20 to 40 means 21 tiles. (20 = tile 1, 21 = tile 2 ... 39 = tile 20, 40 = tile 21)

You would then start drawing the map at positions x = 30 - 10 = 20, y = 60 - 10 = 50, and end at x = 30 + 10 = 40, y = 60 + 10 = 70, but you need to check the borders so you don't go past the size of the array in either direction in x and y.

You have to decide on:

1. The character must always be in the centre: this means the border of the map somehow must be allowed to move to the centre.

2. The character is allowed to move around on the map freely without being in the centre, and that moving beyond a certain point bumps the map one or more tiles.  This allows the map border to never be drawn inside the visible area, and the character to move all the way to the edge of the screen, when the character reaches the end of the map.

3. Make enough bushes and mountains to never allow the border of the map to come inside of the screen.

Sorry if I am not clear enough, I just brainstormed a bit here.  Just ask if anything is unclear.

Edit: I also think that reading about prototypes in JavaScript will come in handy too.  That will allow you to do some class/object oriented-like kind of things that you can use for the tiles like:

```var tile = function()
{
this.fileName = 0;
this.solid = false;
this.somethingelsethatyouneed = something;
}

tile[0] = new tile;
tile[0].filename = 'somefile';```

etc...

I am not sure if this is the best way, but you get the idea.  If you want to see the details how I did something similar, view the source code of:

http://stonearts.org/jsgame/3/

I even started on a tile editor once that I never finished because I needed to do some major restructuring to make an effective GUI in JS:

http://stonearts.org/jsgame/1/

(And I really consider myself a n00b...)

Ah Thx for the Replys Im very Thankfull for your feedback and im Sorry that i haven't replied back in such a long time. Been to busy with Work and my Personal Life.

Anyways to the code, i been trying out the things you been telling me and it seems to quite frankly work properly. I will continue evolving the game and will contact you if there are other types of questiones i have.

### In Topic: Best way to handle input in SDL?

04 January 2014 - 06:46 PM

I've always used to expose all current user input in a singleton called InputManager, which has it's state updated on every frame. On every frame, i poll SDL input for changes, and update the state of InputManager. Then, all my game objects are able to ask it for the state of keys like this:

InputManager.isKeyDown('A');

InputManager.isKeyDown('Left');

InputManager.isKeyDown('Right');

Do you guys think this is a good way of handling input? How do you do it in your engines?

Hiya Vinny

My preferd way of handling input would be event driven. I just think its a much better and cleaner way of handling inputs and events all togheter. Then again thats my opinion and maybe someone else has better points on handle keyboard input.

If you need some examples check http://lazyfoo.net/tutorials/SDL/index.php Lesson 3 for event and Lesson 4 for keyboard handling

### In Topic: how to think like a programmer

19 April 2013 - 01:23 AM

I'm going to be making my own game soon without using tutorials and just using what I know. What I'm having trouble coming up with is the logic of the game. Things like upgrading weapons and towers, how to make ai detect when theres something in their way, things like that. Are there any books or tutorials that help with this kind of thinking while making a game?

Hm well there are surely many ways how to plan out a game before starting, but my favorite one is surely the UML. You can use the UML to have a graphical view, of the class and actions in them. Point out of which classes you will need for your game. We use for example the Tower Defence, a  very loved game by many. Now what does a Tower Defence need? We surely need a Tower class since there are towers, surely enemies aka the waves that appear, and maybe a upgrade class for some upgrades the towers need. These are just the logical ones for the game you need, now for the needed ones. You need Initialize that handles all the loading of data, a event which handles all input events, loop which handles all the data updates, render which handles all the rendering of anything that  shows up on the screen and cleanup that simply cleans up any resources loaded. These needed ones, i got from the sdltutorials on how to make a tictactoe, if you wish to check out here you go: http://www.sdltutorials.com/sdl-tutorial-basics . Now next after you got all does things we use a Sequenzdiagramm. In there you will produce a graphical display on how the programm handles, like how does the application start? Which class will come first and so on. These are pretty much roughly said the main ones who are needed to think like a programmer while aiming for a game.

I do hope i could help you with my ideas and wish you a great day

Yours Truly

### In Topic: Starting a FPS game ideas on where to begin?

19 April 2013 - 01:08 AM

Hi ,

I want to create a good FPS game in 3D in home environment and I wondering how I should start with it ? I don't have any experience either in Programming , Modelling textures or animations. I was thinking about Unity 3D because I think I should start with it , is it good idea ? I don't want start with for example programs like FPS Creator because that type of programs are just like "LEGO Programs" because you must just Put everything in right place and compile and usually with that type of programs there are many models and textures are included. So guys any idea how unexperienced Being should start making a game ?

Thanks

MikeTheBigBoos

Well if you wish to create a FPS game you first of all have to get into the Basics. This can be completed if you work with already existing engines to create games. One of many as you pointed out is Unity 3D but, there is also UDK and the Blender Engine. Just don't forget if you don't have Programming or Modelling skills, it will become very hard to create a decent game with does two engines. My advice before even starting to create a game is to have a decent knowledge of a programming language. For example : Java, Python, C#, C++, Html5. You can pick anything from does really just before choosing please look into them and get some basic knowledge in to which way you wish to programm. If you wanna get more into the basic games like minecraft or similiars choose java or c++ if your into web browser games, choose Html5 or even C#. If this all seems hard to you, just watch some programming tutorials, or how to make games on youtube. There are surely many tutorials to help newcommers into the gamedesigning world. Just a little warning, you may get stressed at your first programms. Don't beworried, this is normal since it means your making progress in learning and do not forget making a game isn't so easy if you wanna start programming games. Even i, who is at a Programming School in Switzerland, have not yet finished my game. And trust me i am trying to finish this but it is hard to finish if you want something decent.

I hope i could help you and wish you a nice Day