Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your help!

We need 1 more developer from Canada and 12 more from Australia to help us complete a research survey.

Support our site by taking a quick sponsored survey and win a chance at a $50 Amazon gift card. Click here to get started!

Before I learned the ++ ..

  • You cannot reply to this topic
8 replies to this topic

#1 Erik Rufelt   Crossbones+   -  Reputation: 4930


Posted 22 October 2013 - 09:29 PM

Last modified January 2001, good old days.. ^^

// Global
struct Global
	// Windows stuff
	HINSTANCE					hInstance;
	HWND						hWnd;
	HDC							hDC;
	HGLRC						hRC;
	bool						active_app;
	bool						pressed_keys[256];
	bool						old_keys[256];
	// Direct Input
	//BYTE						di_buffer[256];
	// Screen info
	GLushort					screen_width;
	GLushort					screen_height;
	GLushort					bit_depth;
	// Loop done
	GLboolean					done;
	// Controls
	GLboolean					forward_pressed;
	GLboolean					backward_pressed;
	GLboolean					left_pressed;
	GLboolean					right_pressed;
	GLfloat						turn_angle;
	GLfloat						look_angle;
	GLboolean					new_left_button;
	GLboolean					new_right_button;
	GLboolean					left_button_pressed;
	GLboolean					left_button_was_pressed;
	GLboolean					right_button_pressed;
	GLboolean					right_button_was_pressed;
	GLboolean					shift_pressed;
	GLshort						mouse_x;
	GLshort						mouse_y;
	GLshort						mouse_x_start;
	GLshort						mouse_y_start;
	GLfloat						mouse_x_fraction;
	GLfloat						mouse_y_fraction;
	GLfloat						mouse_x_start_fraction;
	GLfloat						mouse_y_start_fraction;
	// FPS
	GLfloat						fps;
	// Global time (in milliseconds)
	unsigned long				time;
	// Trig tables
	GLfloat						cosTable[36000];
	GLfloat						sinTable[36000];
	// Main menu
	GLshort						main_menu_selection;
	GLshort						main_menu_which_menu;
	GLshort						main_menu_selection_red_change;
	GLshort						main_menu_selection_green_change;
	GLfloat						main_menu_selection_red;
	GLfloat						main_menu_selection_green;
	GLfloat						main_menu_x_move;
	GLfloat						main_menu_y_move;
	GLfloat						main_menu_points_x[11][11];
	GLfloat						main_menu_points_y[11][11];
	GLboolean					main_menu_up_pressed;
	GLboolean					main_menu_down_pressed;
	GLboolean					main_menu_confirm_pressed;
	GLfloat						angle;
	// Game state
	GLshort						game_state;
	GLboolean					end_game;
	// Camera
	GLfloat						camera_offset_x;
	GLfloat						camera_offset_y;
	GLfloat						camera_offset_z;
	GLfloat						camera_rot_x;
	GLfloat						camera_rot_y;
	GLfloat						camera_rot_z;
	// Textures
	GLuint						*textures;
	GLushort					texture_count;
	GLshort						at_texture;
	TextureFilePtr				texture_files;
	GLshort						current_texture;
	GLshort						added_textures;
	GLshort						num_global_textures;
	// Global textures
	GLshort						font_texture;
	GLshort						button_mark_texture;
	GLshort						selection_texture;
	GLshort						statusbar_texture;
	GLshort						buildbar_texture;
	GLshort						minimap_texture;
	GLshort						blood_texture;
	GLshort						gys_barracks_selection_texture;
	GLshort						gys_bc_selection_texture;
	GLshort						gys_utsatt_selection_texture;
	GLshort						cancel_button_texture;
	GLshort						grass_texture;
	GLshort						main_menu_texture;
	GLshort						single_texture;
	GLshort						host_texture;
	GLshort						join_texture;
	GLshort						options_texture;
	GLshort						quit_texture;
	// Sky dome
	GLshort						skydome_texture;
	GLshort						cloud_texture;
	GLshort						sky_box_start_texture;
	// Floor/wall textures
	GLshort						floor_texture;
	GLshort						wall_texture;
	// Players
	PlayerPtr					players;
	PlayerPtr					camera_player;
	// Structures/units
	UnitPtr						units;
	StructurePtr				structures;
	SelectionPtr				selection;
	char						*mouse_target;
	char						*highlighted_target;
	unsigned int				next_unit_id;
	unsigned int				next_structure_id;
	BloodSourcePtr				blood_sources;
	BloodPtr					blood;
	ProjectilePtr				projectiles;
	TerrainEffectPtr			terrain_effects;
	// Models
	SMPtr						model_gys_utsatt;
	SMPtr						model_gys_bc;
	SMPtr						model_gys_barracks;
	SMPtr						model_gys_arm;
	SMPtr						model_gys_leg;
	SMPtr						model_gys_torso;
	SMPtr						model_gys_head;
	// Resources
	GLshort						minerals;
	GLshort						gas;
	// Chat
	ChatMPtr					chat_messages;
	GLboolean					chatting;
	GLshort						chat_message_length;
	GLubyte						chat_message[256];
	// Button marks
	ButtonMarkPtr				button_marks;
	// Network
	Server						server;
	Client						client;
	GLshort						net_type;
	MessagePtr					messages;
	GLshort						ip_string_length;
	GLubyte						ip_string[256];
	// World
	GLfloat						world_y[101][101];
	GLfloat						world_shade[101][101];
	GLfloat						bottom_y;
	GLfloat						world_y_change[101][101];
	WorldTriangle				world_triangles[100][100][2];
	char						text[256];
	char						text2[256];
	GLboolean					do_it;
	FILE						*log_file;
	GLboolean					compressed;
typedef struct Global Global;

At least functions had representative names..

void Draw3DModelFast(SMPtr model, float offset_x, float offset_y, float offset_z,
					float rotation_x, float rotation_y, float rotation_z)
	BonePtr					bone = 0;
	int						i;
	int						j;
	float					x;
	float					y;
	float					z;
	float					shade;
		if(g.current_texture != (model->triList[i].texture+model->firstTexture))
			glBindTexture(GL_TEXTURE_2D, g.textures[model->triList[i].texture+model->firstTexture]);
			g.current_texture = model->triList[i].texture + model->firstTexture;
			x = model->vertexList[model->triList[i].vertex[j]].point.x;
			y = model->vertexList[model->triList[i].vertex[j]].point.y;
			z = model->vertexList[model->triList[i].vertex[j]].point.z;
			shade = model->vertexList[model->triList[i].vertex[j]].shade;
			glColor4f(shade, shade, shade, 1.0f);
			RotatePt(&x, &y, &z, rotation_x, rotation_y, rotation_z);
			x += offset_x;
			y += offset_y;
			z += offset_z;
			glVertex3f(x, y, z);
}// Draw3DModelFast


#2 Alpha_ProgDes   Crossbones+   -  Reputation: 5309


Posted 22 October 2013 - 09:50 PM

C++ with functions, eh? ;)

External Articulation of Concepts Materializes Innate Knowledge of One's Craft and Science
Beginner in Game Development? Read here.
Super Mario Bros clone tutorial written in XNA 4.0 [MonoGame, ANX, and MonoXNA] by Scott Haley
If you have found any of the posts helpful, please show your appreciation by clicking the up arrow on those posts Posted Image

#3 wintertime   Crossbones+   -  Reputation: 3349


Posted 23 October 2013 - 02:39 AM

Aww, that looks a bit like you had switched away from COBOL shortly before.huh.png

#4 unbird   Crossbones+   -  Reputation: 7496


Posted 23 October 2013 - 05:15 AM

It's not that bad. E.g. there's only one global variable wink.png

#5 Erik Rufelt   Crossbones+   -  Reputation: 4930


Posted 23 October 2013 - 03:05 PM

Haha true :) The real wtf is what I could possibly have compared it with when I named that function Draw3DModelFast :)

#6 fastcall22   Crossbones+   -  Reputation: 6262


Posted 23 October 2013 - 03:23 PM

A sin table and a cos table?! Precision to the 100th degree? You must have had quite a bit of ram back then to afford such luxuries.
gzip: H4sIAAAAAAAEAG1QTUvEMBC991e8nvaiFfYoS7yo sLCo6MnjtJ1ugmkiyWRL/72z3T1YEQIJ8z4zA2Xp yPvt1qBpGrRFIJZkk9FyRyUzHCbKIHgn4hnZOrm1 TD0mG0HCCs+QGDGWziKXI6Wm2n++GYwUVH2mrGEE PnGCVQ8K8+JYfXA6URDEQfMZh5h6g5eoAlWJdeEI bbH2qYZf7XMUfw8f/Q0oMeZYNL9/WHF0uFEshvMr XYujd9SycFb+F18QcSOvlJauZ8ejqevdnV7/d550 e0t6prmunh73Bu+vz4c/XUeOQXfJgvKNkhf95U8/ Dtgmy5IBAAA=

#7 Erik Rufelt   Crossbones+   -  Reputation: 4930


Posted 23 October 2013 - 06:29 PM

A sin table and a cos table?! Precision to the 100th degree? You must have had quite a bit of ram back then to afford such luxuries.

Hehe, I doubt those were even a speed gain in 2001, probably a remnant from my 75mhz Mac :)

#8 Krohm   Crossbones+   -  Reputation: 4127


Posted 24 October 2013 - 02:03 AM

Ouch, I'm doing that right now for my JavaScript... 

#9 wintertime   Crossbones+   -  Reputation: 3349


Posted 24 October 2013 - 03:45 AM

You know, arithmetic is getting faster and faster, but memory reads improve much slower, especially when having a large, likely uncached table.