Jump to content

  • Log In with Google      Sign In   
  • Create Account


farmdve

Member Since 01 Apr 2012
Offline Last Active Nov 07 2013 06:20 PM
-----

#5099098 Guidance for my son...

Posted by farmdve on 06 October 2013 - 06:49 AM

Hi,

 

First off, congratulations on actually trying to help him (instead of dissuade this idea).

 

As your son is 12yo, and he'll probably start working (if everything goes well) around 18, he'll have a lot of ground ahead of him.

I say this because some of the technologies we use today to make games actually came to life in the last 6 years, so it is possible that some of them will fade as well, giving room for something even better.

This takes me to my point: don't focus on one specific technology, but on the general knowledge for now.

 

Some programming basics with Python or other higher level language would be a great starting point. You could take a look on pygame, or even Flash, to create this basics on what's a game, how it works by a bird's eye and then move up to something more complex.

 

This way he can then decide if he actually want to be a programmer or a game designer or maybe something else; as he probably doesn't understand the difference yet, as I didn't when I started as a kid.

I don't have anything to add, but never do Flash it's a technology that should die, it's a resource hog and has horrible performance even on high-end machines. Hopefully it will be replaced by HTML5.




#5098919 Guidance for my son...

Posted by farmdve on 05 October 2013 - 06:15 AM

My suggestion is to take it easy, a 10 year old is what, 3rd grade? Making games involves math that is more complex that I who am 20 can't do. Plus, being 10 his mind is not developed enough yet, the scope of what could be understood and comprehended is small.

 

Hell, I only understood the meaning of some events that happened in my life when I was 15-16 let alone if I was 10.




#5095225 [SOLVED] C++ Sockets - Bytes Left

Posted by farmdve on 19 September 2013 - 12:08 PM

The size of a structure can actually be reduced by just swapping some variables around, you can try to align them too.




#5094352 2d tile map

Posted by farmdve on 15 September 2013 - 06:56 PM

Lucky you, I recently wrote exactly what you describe, though for me the letters have a different meaning.

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <assert.h>

#include "map.h"

int TileNum(FILE *fp)
{
	int c = 0;
	char ch = '\0';
	
	while(ch != EOF) 
	{
		ch=fgetc(fp);
		if(ch != '\n' && ch != EOF) // don't increment on EOF and newline
			c++;
	}
	
	rewind(fp);
	
	return c;
}

int GetTileIdentifier(int c)
{
	switch(c)
	{
		case 65:
			return 1;
		break;
		case 66:
			return 2;
		break;
		case 88:
			return 3;
		break;
		case 90:
			return 4;
		break;
		case 58:
			return 3;
		break;
		default:
			return 3;
		break;
		
	}
}

int parse_map()
{
	FILE *fp = fopen("map.txt", "r");
	if(!fp)
		return -1;

	Map = malloc(sizeof(struct _Map));
	if(!Map)
		return -1;
		
	Map->tile_num = TileNum(fp);
	assert(Map->tile_num > 0);
	
	Map->tile = calloc(Map->tile_num, sizeof(struct Tile));
	if(!Map->tile)
		return -1;
	/*	
	for(int j = 0; j < Map->tile_num; j++)
	{
		Map->tile[j] = NULL;
		Map->tile[j] = malloc(sizeof(struct Tile));
		if(!Map->tile[j])
			return -1;
	}
	*/
	
	
	char ch;
	int i = 0;
	int row = 0, col = 0, prev_col = 0, tiles_per_row = 1;
	Map->tp_rows = malloc(1*sizeof(int));
	Map->rows = 1;

	while((ch = fgetc(fp)) != EOF)
	{
		if(ch == '\n')
		{
			LEVEL_WIDTH = TILE_WIDTH * col;
			LEVEL_HEIGHT += TILE_HEIGHT * row;
			row++;
			Map->tp_rows = realloc(Map->tp_rows, ((row+1)*sizeof(int)));
			(Map->rows)++;
			col = 0;
			tiles_per_row = 1;
			continue;
		}
		Map->tp_rows[row] = tiles_per_row;
		Map->tile[i].type = GetTileIdentifier(ch);
		Map->tile[i].x = (col * TILE_WIDTH);
		Map->tile[i].y = (row * TILE_HEIGHT);	
		Map->tile[i].w = TILE_WIDTH;
		Map->tile[i].h = TILE_HEIGHT;
		
		/* 
		 * Since 'A' in the map represents the
		 * player it's also treated as a tile and thus
		 * placed on the map as such but we don't
		 * want that and we manually replace with 'X'
		 * as a non-solid tile. Not exactly the best solution
		 * I guess.
		 */
		switch(Map->tile[i].type)
		{
			case ENUM_PLAYER:
				player.pos.x = (col * TILE_WIDTH);
				player.pos.w = TILE_WIDTH;
				player.pos.h = TILE_HEIGHT;
				player.pos.y = (row * TILE_HEIGHT);
				Map->tile[i].type = ENUM_TILE_AIR;
				Map->tile[i].sY = 0;
				Map->tile[i].sX = 32;		
			break;
			case ENUM_TILE_AIR:
				Map->tile[i].sY = 0;
				Map->tile[i].sX = 32;
			break;
			case ENUM_TILE_DIRT:
				Map->tile[i].sY = 0;
				Map->tile[i].sX = 0;			
			default:
				Map->tile[i].sY = 0;
				Map->tile[i].sX = 0;
			break;
		}
		
		i++;
		tiles_per_row++;
		col++;
	}

	fclose(fp);
	
	return 0;
}

inline int get_tile_index(int row, int col, int tiles_per_row)
{
	return (row * tiles_per_row) + col;
}


Modify as needed.




#5090703 An updated version of 'languages' article?

Posted by farmdve on 31 August 2013 - 07:26 PM

http://www.gamefromscratch.com/post/2011/08/04/I-want-to-be-a-game-developer.aspx

This article was written 2 years ago, and is very informative about each game development language, but 2 years sounds like too much for how events quickly change now, XNA is partially dead, more books released, etc..

 

Is there a newer article of that kind of information? and is C++ still a bad choice (with the introduction of SFML 2.1 and SDL 2)?

I thought that the industry standard for PC games(not sure for other platforms) was C++ so I do not believe it was ever bad to begin with, just too complex at times with STL,vectors,OOP,maps,iterators and whatnot




#5011306 Question about use of JNI

Posted by farmdve on 16 December 2012 - 11:13 AM

Just so you guys know, but Android has a per-process limit of 16-24 megabytes of RAM usage. Try not to get over that limit. If you are going to call JNI functions often and allocate/free memory on each call, you'd need to keep JNI initialized as malloc-ing and free-ing is expensive, I found that out the hard way.

And if you need to update Java from the JNI side, you'd need to free the local reference.


#5009989 2D collision resolution code not behaving properly.

Posted by farmdve on 12 December 2012 - 04:25 PM

Long story short, I followed the SDL tutorial on LazyFoo here http://lazyfoo.net/S...son29/index.php and wrote the game from scratch in C(since the examples were C++), but borrowed some of the functions.

What is happening is that the collision code is working, but not entirely. If I were to hit a wall, and continue to walk towards it(and being unable to pass through it obviously) and at the same time try to move in a different direction(but not the opposite to the wall) I can't move.

This is my if/else statement

if(touches_wall(player.box))
{
	if(player.box.x < player.prev_x)
	{
		player.box.x += GetVelocity(player, 0);
	}
	else if(player.box.x > player.prev_x)
	{
		player.box.x -= GetVelocity(player, 0);
	}

	if(player.box.y > player.prev_y)
	{
		player.box.y -= GetVelocity(player, 1);
	}
	else if(player.box.y < player.prev_y)
	{
	   player.box.y += GetVelocity(player, 1);
	}
}

player.box.x and player.box.y are the current positions of the player on the X and Y axis respectively. player.prev_x and player.prev_y are the previous positions.
GetVelocity pretty much returns some static hardcoded values of the velocity for each axis(depending on the second argument being 0 or 1).

My previous collision handling code was this huge one http://pastebin.com/mrFkLTLH but while it worked the way I wanted it allowed under some conditions the object to pass through the wall near the corners.

Here's a picture of a more detailed explanation; http://i.imgur.com/Rn7MY.png
Where the arrows are, I basically make the object go left, let it collide and then either go up or down, while still going left, but it will stay still and won't move either way.
With my previous large code that I just pasted on pastebin, where the small blue lines are on the screenshot, that's where the object passed through the wall on some conditions.

So I basically need a solution on how to fix this. I've been working on that since last night, to the point where I wrote the same code over and over again, expecting a different result.

EDIT:It is fairly obvious to me, that since my collision code is inside a single if-statement, and I am indeed colliding with a wall, while trying to move up or down, either of the sub-statements always execute thus preventing me to move. No idea how to fix it though,


#4927233 Newbie here, I wish to start.

Posted by farmdve on 01 April 2012 - 12:05 PM

Well, it's obvious I am a newbie. I only know a bit of C, I am a newbie at C, but this hasn't stopped me from writing an application I want.
I was able to write myself a GPU temp monitor using AMD's ADL library. It's multithreaded so each thread is checking the corresponding sensor for overheats.
I am in the process of writing an HTML parser of sorts(not a library, but one that uses it) using cURL then piping to htmlTidy to fix up the document then piping the fixed document to libxml2 for the actual HTML parsing and finally through PCRE for regular expressions.

Well, I pretty much pointed out that I wish to write a game in pure C. I already have SDL. Now the problem I am facing is that, I don't know anything about game programming. Neither terminology(shading,voxel,polygons and the list goes on), neither about geometry involved, nor the concepts and maths of "Depth,Gravity,Collision". And for instance how walking on some texture, you don't fall off of it.

So if possible, can you point me to some resources on how all these stuff work. And perhaps how to start.


PARTNERS