Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (EternallyCurious, Quad, vicknick), 700 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 4 of 6 1 2 3 4 5 6
Re: What's (currently) your favourite snippet of code? [Re: FBL] #444690
08/16/14 21:18
08/16/14 21:18
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
Code:
"".GetType()



Visit my site: www.masterq32.de
Re: What's (currently) your favourite snippet of code? [Re: MasterQ32] #444732
08/17/14 18:57
08/17/14 18:57
Joined: Dec 2008
Posts: 1,660
North America
Redeemer Offline
Serious User
Redeemer  Offline
Serious User

Joined: Dec 2008
Posts: 1,660
North America
Code:
for( v=0; v<TEXTURESIZE; v++ ) {
	SDL_GetRGB(getPixel(texture,u,v),screen->format,&b,&g,&r);
	color = SDL_MapRGB(screen->format,r,g,b);
	while( texelcount<=max(1.0,texelsize) && y<camera->winy+camera->winh ) {
		if( y>=camera->winy ) {
			*(Uint32 *)((Uint8 *)p + scanline)=color; // draw pixel
			scanline += scanwidth;
		}
		y++;
		texelcount+=min(texelsize,1.0);
	}
	texelcount -= max(1.0,texelsize);
	if( y>=camera->winh+camera->winy )
		break;
}


Column-based texture mapping on a per texel basis. It seems obvious but I just realized it a year ago, and it massively improved the speed of my raycaster when the camera was positioned close to walls. UV coordinates are recalculated only when the end of the texel is reached (instead of for every pixel), and if texelsize<0 the more obvious per-pixel method is used instead.

Also:
Code:
fld fnum
fistp inum


Fast float to integer conversion in x86. Weirdly enough I've found that many compilers will not do this. I discovered the trick several years ago and then found sometime later that John Carmack did the same thing in Quake 2.

Originally Posted By: Superku
Code:
my.pan = your.pan + random(360);


Where did you find this? grin


Eats commas for breakfast.

Play Barony: Cursed Edition!
Re: What's (currently) your favourite snippet of code? [Re: Redeemer] #444738
08/17/14 19:28
08/17/14 19:28
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
Devil City.

Re: What's (currently) your favourite snippet of code? [Re: FBL] #444743
08/17/14 20:33
08/17/14 20:33
Joined: Dec 2008
Posts: 1,660
North America
Redeemer Offline
Serious User
Redeemer  Offline
Serious User

Joined: Dec 2008
Posts: 1,660
North America
Originally Posted By: Firoball
Devil City.

Ich verstehe ganz nicht, ist das irgendeine Art von Spiel?


Eats commas for breakfast.

Play Barony: Cursed Edition!
Re: What's (currently) your favourite snippet of code? [Re: Redeemer] #444744
08/17/14 20:36
08/17/14 20:36
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859

Re: What's (currently) your favourite snippet of code? [Re: FBL] #444746
08/17/14 20:51
08/17/14 20:51
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Devil City was THE game back then in the old forum days, with 80-120 enemy types, a cool blocky outdoor level covered in fog and a mediocre sewer level. Sadly and not surprisingly it was mostly a hoax, and "Devil" was not the coder he promised to be.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: What's (currently) your favourite snippet of code? [Re: Superku] #444748
08/17/14 21:25
08/17/14 21:25
Joined: May 2002
Posts: 7,441
ventilator Offline
Senior Expert
ventilator  Offline
Senior Expert

Joined: May 2002
Posts: 7,441
was he the guy who left the forum by making a last post where he regretted that he wasted his whole youth with gamestudio (instead of chasing girls)? oh... all the drama this forum has seen... laugh

Re: What's (currently) your favourite snippet of code? [Re: ventilator] #444782
08/18/14 16:13
08/18/14 16:13
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
Originally Posted By: ventilator
was he the guy who left the forum by making a last post where he regretted that he wasted his whole youth with gamestudio (instead of chasing girls)? oh... all the drama this forum has seen... laugh


yeth.
And I think he called me some sort of nazi or the like tongue

Re: What's (currently) your favourite snippet of code? [Re: FBL] #444843
08/19/14 19:51
08/19/14 19:51
Joined: Sep 2003
Posts: 9,859
F
FBL Offline
Senior Expert
FBL  Offline
Senior Expert
F

Joined: Sep 2003
Posts: 9,859
Code:
#include <acknex.h>
#include <windows.h>

typedef int HKEY;
typedef int REGSAM;

long WINAPI RegEnumKeyEx(
	HKEY hKey,
	DWORD dwIndex,
	char *lpName, 
	long *lpcName,
	long *lpReserved, 
	char *lpClass, 
	long *lpcClass, 
	FILETIME *lpftLastWriteTime);
	
long WINAPI RegOpenKeyEx(HKEY hKey, char *lpSubKey, DWORD ulOptions, REGSAM samDesired, HKEY *phkResult);

long WINAPI RegCloseKey(HKEY hKey);

function main()
{
	HKEY hTestKey;
	if(RegOpenKeyEx(HKEY_CURRENT_USER,
		"SOFTWARE\\Unity Technologies",
		0,
		KEY_READ,
		&hTestKey) == ERROR_SUCCESS )
	{
		error("Traitor!");
		RegCloseKey(hTestKey);
	}
	else
	{
		error("All fine!");
	}
   
}



Snippet taken from Prince of Lotteria. grin

Re: What's (currently) your favourite snippet of code? [Re: FBL] #444847
08/19/14 20:25
08/19/14 20:25
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
haha grin


POTATO-MAN saves the day! - Random
Page 4 of 6 1 2 3 4 5 6

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1