Programming Pimpage Thread

Grab your favourite IDE and tinker with the innards of game engines

Programming Pimpage Thread

Postby Surfa on Wed Mar 24, 2010 10:08 pm

Now I noticed a slight increase in coders on interlopers recently so I figure that we (not sure if I count as a coder) deserve a little thread of our own.

So here goes a coder pimpage thread.

Post any exciting piece of code you are working on be it a modding tool or a database editor it really doesn't matter. Now this may not catch on or it could even turn into a look how awesome coder/zombie are thread although it takes off it could also be used to share code snippets.

I will start it off with a small tool I decided to work on.
It basically allows for easy generation of .qc files for static props. Eventually I hope to turn it into a full .qc editor with syntax highlighting and such.
Image
Image

So post your stuff.
Last edited by Surfa on Thu Mar 25, 2010 9:22 pm, edited 1 time in total.
Surfa
May Contain Skills
May Contain Skills
 
Joined: Sun Dec 30, 2007 3:04 pm

Re: Code Pimpage Thread

Postby Major Banter on Wed Mar 24, 2010 10:13 pm

Code: Select all
"WorldVertexTransition"
{
   "$basetexture" "Nature/forest_dirt_04"
   "$basetexture2" "FZTextures/FZ_floor_leaves2"
   "$surfaceprop" "dirt"
   "$blendmodulatetexture" "nature/blendtexture01"
   "%detailtype" "forest_floor_01"
}



I continue to find VMT construction hideously satisfying. Going to experiment with multiple Alphas and see if I can't find out why valve didn't like using more than 2.

Also going to make some comparison textures; never found the blendtexture raw VTFs, so I'll just make a few up to number 9 or something and see what effects I get.

Not the most amazing of code, but I like it.
ImageImageImage
Major Banter
Veteran
Veteran
 
Joined: Tue Apr 01, 2008 10:52 pm
Location: UK

Re: Code Pimpage Thread

Postby Zipfinator on Thu Mar 25, 2010 12:23 am

There's only a blendtexture01. Don't bother finding others. I've seen the .vtf in the GCF and there are no others around it.
Image
|Pipe Dream|City 17: Episode 1|
User avatar
Zipfinator
Veteran
Veteran
 
Joined: Thu Dec 21, 2006 6:03 pm
Location: California

Re: Code Pimpage Thread

Postby Noodles on Thu Mar 25, 2010 1:34 am

Code: Select all
   "...............if (Key.isDown(Key.UP) && canijump){
      jump = -15;
      canijump = false;
      }
      
   hero.y += jump;
   
   if (Key.isDown(Key.RIGHT)){
      hero.scaleX = +1;
      bg.x += -5;
      holerer.x += -5;
      holerer2.x += -5;
      plat.x += -5;
      plat2.x += -5;
      tunnel.x += -5;
      hero.gotoAndStop('walking');
      }.................."


;) No one said it had to be C++!
'English as tuppence, changing yet changeless as canal water, nestling in green nowhere, armoured and effete, bold flag-bearer, lotus-fed Miss Havershambling, opsimath and eremite, feudal, still reactionary Rawlinson End.'
User avatar
Noodles
Pheropod
Pheropod
 
Joined: Mon May 09, 2005 3:52 pm
Location: Sweden

Re: Code Pimpage Thread

Postby Unreal_Me on Thu Mar 25, 2010 2:59 am

*snip* turns out the above was AS3


if somebody can actually find a useful implementation of the bozo sort algorothm, I'll be throughly impressed
Last edited by Unreal_Me on Thu Mar 25, 2010 5:53 pm, edited 1 time in total.
User avatar
Unreal_Me
Regular
Regular
 
Joined: Fri Aug 14, 2009 4:14 am
Location: The middle of nowhere, the center of everywhere

Re: Code Pimpage Thread

Postby city14 on Thu Mar 25, 2010 3:00 am

Action Script?

Cool stuff
coder0xff wrote:I wonder if Gabe ever lies in bed at night, thinking about all the fat jokes, and just cries himself to sleep, wiping his tears away with one-thousand dollar bills.
User avatar
city14
Pheropod
Pheropod
 
Joined: Tue Jun 16, 2009 8:35 pm
Location: Troutdale, Oregon

Re: Code Pimpage Thread

Postby .treeturtle-- on Thu Mar 25, 2010 3:06 am

what is that for, looks like a 2d game in C,
if so your jump code looks like it would fail epicly judging that hero.y is the players vertical location, but then again, i really don't know. you should elaborate

oh, and since sharing random code seems to be the thing to do then TADA! its LUA!
this is some simple trig stuff to make a ball follow the mouse. It took me a while to think of but I finally did. Now, a day later I see that I need to completely rewrite it and start over using a different method if i hope to fully get the desired movement... curse you math!
Code: Select all
function love.update(dt)
mouseX = love.mouse.getX()
mouseY = love.mouse.getY()

difinY2 = (mouseY - pointtwoY)
difinX2 = (mouseX - pointtwoX)

--POINT ONE, MOVE TOWARDS THE MOUSE
acthyp2 = math.sqrt( (difinX2 * difinX2) + (difinY2 * difinY2) )
proportion2 = (speed2 / acthyp2)
yforce2 = (difinY2 * proportion2)
xforce2 = (difinX2 * proportion2)
pointtwoX = pointtwoX + (xforce2 * dt * 1)
pointtwoY = pointtwoY + (yforce2 * dt * 1)

love.graphics.draw(ball2, pointtwoX, pointtwoY, r ,sx,sy,32,32)
-----------------------------
difinY = (pointtwoY - ballY)
difinX = (pointtwoX - ballX)


--BALL MOVE TOWARDS POINT TWO (which is actually point one)
acthyp = math.sqrt( (difinX * difinX) + (difinY * difinY))
proportion = (speed / acthyp)
yforce = (difinY * proportion)
xforce = (difinX * proportion)
ballX = ballX + (xforce * dt * 1)
ballY = ballY + (yforce * dt * 1)
love.graphics.draw(ball, ballX, ballY, shiprotation ,sx,sy,32,32)

--FACE THE MOUSE
if pointtwoX ~= (ballX+32)then
   if pointtwoX > (ballX+32) then
   shiprotation = (math.atan(difinY / difinX))
   end
   if pointtwoX < (ballX+32) then
   shiprotation = (math.atan(difinY / difinX) + math.rad(180))
   end
else
   if pointwoY > (ballY+32) then
   shiprotation = (math.rad(90))
   else shiprotation = (math.rad(270))
   end
end
end
turtle
User avatar
.treeturtle--
Regular
Regular
 
Joined: Wed Dec 16, 2009 5:06 am
Location: Michigan

Re: Code Pimpage Thread

Postby coder0xff on Thu Mar 25, 2010 4:29 am

No offense Banter, but I think VMT script - though maybe difficult - counts as coding just about as much as HTML does (which means not at all). Specifically, it's a document markup format, not a programming language.

Anyway, I suppose I'll avoid posting in here myself, unless it's something I really think you guys could use, but I'll be sure to drop in and see what's going on and give some crits.
User avatar
coder0xff
Veteran
Veteran
 
Joined: Fri Jun 13, 2008 1:51 am

Re: Code Pimpage Thread

Postby coder0xff on Thu Mar 25, 2010 4:51 am

.treeturtle-- wrote:oh, and since sharing random code seems to be the thing to do then TADA! its LUA!
this is some simple trig stuff to make a ball follow the mouse. It took me a while to think of but I finally did. Now, a day later I see that I need to completely rewrite it and start over using a different method if i hope to fully get the desired movement... curse you math!
Code: Select all
function love.update(dt)
mouseX = love.mouse.getX()
mouseY = love.mouse.getY()

difinY2 = (mouseY - pointtwoY)
difinX2 = (mouseX - pointtwoX)

--POINT ONE, MOVE TOWARDS THE MOUSE
acthyp2 = math.sqrt( (difinX2 * difinX2) + (difinY2 * difinY2) )
proportion2 = (speed2 / acthyp2)
yforce2 = (difinY2 * proportion2)
xforce2 = (difinX2 * proportion2)
pointtwoX = pointtwoX + (xforce2 * dt * 1)
pointtwoY = pointtwoY + (yforce2 * dt * 1)

love.graphics.draw(ball2, pointtwoX, pointtwoY, r ,sx,sy,32,32)
-----------------------------
difinY = (pointtwoY - ballY)
difinX = (pointtwoX - ballX)


--BALL MOVE TOWARDS POINT TWO (which is actually point one)
acthyp = math.sqrt( (difinX * difinX) + (difinY * difinY))
proportion = (speed / acthyp)
yforce = (difinY * proportion)
xforce = (difinX * proportion)
ballX = ballX + (xforce * dt * 1)
ballY = ballY + (yforce * dt * 1)
love.graphics.draw(ball, ballX, ballY, shiprotation ,sx,sy,32,32)

--FACE THE MOUSE
if pointtwoX ~= (ballX+32)then
   if pointtwoX > (ballX+32) then
   shiprotation = (math.atan(difinY / difinX))
   end
   if pointtwoX < (ballX+32) then
   shiprotation = (math.atan(difinY / difinX) + math.rad(180))
   end
else
   if pointwoY > (ballY+32) then
   shiprotation = (math.rad(90))
   else shiprotation = (math.rad(270))
   end
end
end


Got some suggestions for ya. If you are just trying to make pointtwo move towards the mouse (and it looks like the further away it is the less aggressively it accelerates as you have it now? is it supposed to be like gravity? lemme know cause the equation's completely different). This equation makes it move fast if it's far away, and slows as it approaches the mouse, and is correctly integrated over time if you have loss of frame rate.

Code: Select all
//assuming dt is time delta
difinY2 = (mouseY - pointtwoY)
difinX2 = (mouseX - pointtwoX)
step = 1 - math.exp(-dt * speed)
pointtwoY += difinY2 * step
pointtwoX += difinX2 * step


If you are trying to do a system where momentum is preserved and force is used to accelerate the point towards the mouse and then decelerate so that it stops when it reaches the mouse, it's a little more difficult (unless you know how).

Also, you may want to look into the function math.atan2(y, x). It automagically determines which quadrant you're in so you don't have to do all that extra stuff you got at the end there.
User avatar
coder0xff
Veteran
Veteran
 
Joined: Fri Jun 13, 2008 1:51 am

Re: Code Pimpage Thread

Postby Major Banter on Thu Mar 25, 2010 12:23 pm

coder0xff wrote:No offense Banter, but I think VMT script - though maybe difficult - counts as coding just about as much as HTML does (which means not at all). Specifically, it's a document markup format, not a programming language.


Fine, if you're going to be like that, you can taste my weapon_AK code when I get home you philistine.

On a side note, HTML is incredibly complicated and I think being elitist about what specifically counts as code is demotivating and decidely arrogant. No offence, that's my reading of what you've typed.

Zipfinator wrote:There's only a blendtexture01. Don't bother finding others. I've seen the .vtf in the GCF and there are no others around it.


I assume it's an Alpha Channel then; could you drop me the path in a PM?
ImageImageImage
Major Banter
Veteran
Veteran
 
Joined: Tue Apr 01, 2008 10:52 pm
Location: UK

Re: Code Pimpage Thread

Postby Noodles on Thu Mar 25, 2010 1:40 pm

@ .treeturtle-- it was AS3, for a sidescroller I made a while ago. Is only a random segment of the code so only half the jump code is there, suffice to say it worked ;)
'English as tuppence, changing yet changeless as canal water, nestling in green nowhere, armoured and effete, bold flag-bearer, lotus-fed Miss Havershambling, opsimath and eremite, feudal, still reactionary Rawlinson End.'
User avatar
Noodles
Pheropod
Pheropod
 
Joined: Mon May 09, 2005 3:52 pm
Location: Sweden

Re: Code Pimpage Thread

Postby .treeturtle-- on Thu Mar 25, 2010 6:13 pm

coder0xff wrote:
Got some suggestions for ya. If you are just trying to make pointtwo move towards the mouse (and it looks like the further away it is the less aggressively it accelerates as you have it now? is it supposed to be like gravity? lemme know cause the equation's completely different). This equation makes it move fast if it's far away, and slows as it approaches the mouse, and is correctly integrated over time if you have loss of frame rate.

If you are trying to do a system where momentum is preserved and force is used to accelerate the point towards the mouse and then decelerate so that it stops when it reaches the mouse, it's a little more difficult (unless you know how).

Also, you may want to look into the function math.atan2(y, x). It automagically determines which quadrant you're in so you don't have to do all that extra stuff you got at the end there.


I'm definitely going to look into math.atan2 thanks
basically, this creates two points, the first point moves at a specified speed always directly at the mouse, the second point does the same but it always moves towards the first invisible point, this second point is where the actual object is. This makes the ball follow the mouse, but not directly, it takes time to make wide turns instead of just going straight at the mouse. It's like a three car train. its based off constantly updating the x and y value of the ball so that its "vector" or hypotenuse is. It works, the problem is that the "train cars" can go on top of each other. I'm redoing it by updating the angle of movement and basing the x y off that, instead of making a "train" which should fix it I think. I've got all the math down on paper but haven't typed it up yet.

this doesn't change the speed based off the distance of the mouse because of the use of "proportion", however i plan on implementing that in the game, which is a prototype for a soon to be iphone game. if i can prove my concept in lua on LOVE ( http://www.love2d.org ) then i'll start on the iphone version
turtle
User avatar
.treeturtle--
Regular
Regular
 
Joined: Wed Dec 16, 2009 5:06 am
Location: Michigan

Re: Code Pimpage Thread

Postby Terr on Thu Mar 25, 2010 6:51 pm

This is an old picture from the pre-rewrite version, but... TF2Maps released a pack of custom materials called "The Swamp Pack". Since I was working on a dependency-solver for custom map content, here's the dependencies (in terms of models, materials, and textures.)
Image
The blue nodes are logical helpers, since model-materials are actually specified based on search paths which must be evaluated.


Major Banter wrote:On a side note, HTML is incredibly complicated and I think being elitist about what specifically counts as code


The Mona Lisa is special, but it isn't "code" either. Nor is written prose like "War and Peace"*. It's not elitist, it's simply that HTML--alone--doesn't have any algorithmic content.

*Some laws/contracts/spreadsheets would qualify as having algorithmic content.
Terr
Sir Post-a-lot
Sir Post-a-lot
 
Joined: Mon Oct 12, 2009 11:35 pm

Re: Code Pimpage Thread

Postby coder0xff on Thu Mar 25, 2010 9:10 pm

Major Banter wrote:On a side note, HTML is incredibly complicated and I think being elitist about what specifically counts as code is demotivating and decidely arrogant. No offence, that's my reading of what you've typed.


Perhaps I am being elitist, since "code" doesn't necessarily mean "programming", but then I guess I could just post pig-latin translations of regular English. :lol:

But if we are to assume that code means programming (which I believe was the intent) then HTML, however complicated is still not programming. The very name itself states that it's a document markup language. Programs take input, perform operations on that input using arithmetic and control structures, and generate output. HTML and VMTs do none of these. They are documents.

Just to clarify, I'm not trying to be mean or offensive, and I in no way take offense. I just feel strongly about this topic (as most programmers do) because people believing that HTML is programming trivializes the skill that it takes to make a real program. I'd like to see HTML make that physics engine recently posted in Random Thread.
User avatar
coder0xff
Veteran
Veteran
 
Joined: Fri Jun 13, 2008 1:51 am

Re: Code Pimpage Thread

Postby Major Banter on Thu Mar 25, 2010 9:20 pm

A code is a rule for converting a piece of information (for example, a letter, word, phrase, or gesture) into another form or representation (one sign into another sign), not necessarily of the same type.


Ergo. Condensing of information. Code is specifically the transference of specific stuff into a different form where it can be read and utilised differently; as said there. Programming is a sub-section of coding. Ergo, chill out and look at my coverted information within these VMTs and .txts; if you're lucky, you can check out me totally destroying a .dll later if VisualStudio decides to work.

Oh, by the way


I NEVER MENTIONED PROGRAMMING.


So chill. Programming = Code. Code does NOT = programming.

Ps: Yes you're better and can program, which is so talented I can't comprehend that shit. But there's no need to be cockend, you're massively superior regardless.


EDIT: Name change = Banter exits through side door. Thank you all.
ImageImageImage
Major Banter
Veteran
Veteran
 
Joined: Tue Apr 01, 2008 10:52 pm
Location: UK
Next

Return to Programming

Who is online

Users browsing this forum: No registered users