5 Replies - 1965 Views - Last Post: 20 September 2012 - 10:14 AM Rate Topic: ***-- 2 Votes

#1 rangerofthewest  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 12
  • Joined: 10-September 12

[C#] Messiest Code I've Written

Posted 12 September 2012 - 02:35 PM

Yeah, I have more messy code, but I am definitley not happy with how this turned out:

if (ragereadyon == true)
            {
                if (Stats.rage == (20 + (Stats.level / 2)) + Skills.SkillHelper.ragemax)
                {
                rageready = "ULTRARAGE READY FOR USE!";
                }
                else
                {
                    ragereadyon = false;
                }
            }
            else
            {
                rageready = "";
            }
           float flash = (float)gameTime.ElapsedGameTime.TotalMilliseconds;
           timer4 -= flash;
           if (timer4 < 1)
           {


               if (ragereadyon == false)
               {
                   ragereadyon = true;
               }
               else
               {
                   ragereadyon = false;
               }

               timer4 = TIMER4;
           }


The context is in a game, which when a meter is full, text starts flashing. The full code, which explains it a bit better, is at this link (in fact, the whole thing's a mess): http://pastie.org/pr...862vbhiw8agydxw

Especially take note the references to figuring out the in-game time. I know this isn't probably the worst code you've seen, but it's definetly the worst one I've seen and written.
NOTE: This code is not for resale. You can use it if you want, but 1) It'd be nice to get some credit and 2) Don't resell it.

Is This A Good Question/Topic? 0
  • +

Replies To: [C#] Messiest Code I've Written

#2 aloneprogrammer  Icon User is offline

  • New D.I.C Head

Reputation: -13
  • View blog
  • Posts: 31
  • Joined: 22-December 10

Re: [C#] Messiest Code I've Written

Posted 12 September 2012 - 09:00 PM

I don't thinkkk... that it is messiest c0de
Was This Post Helpful? 0
  • +
  • -

#3 Gamma Ray  Icon User is offline

  • D.I.C Head

Reputation: 12
  • View blog
  • Posts: 136
  • Joined: 24-September 10

Re: [C#] Messiest Code I've Written

Posted 16 September 2012 - 11:52 AM

I couldn't leave this piece of code crying. <3
if (ragereadyon) {
	if (Stats.rage == 20 + Stats.level / 2 + Skills.SkillHelper.ragemax) {
		rageready = "ULTRARAGE READY FOR USE!";
	} else {
		ragereadyon = false;
	}
} else {
	rageready = "";
}
float flash = (float)gameTime.ElapsedGameTime.TotalMilliseconds;
timer4 -= flash;
if (timer4 < 1) {
	ragereadyon = !ragereadyon;
	timer4 = TIMER4;
}

This post has been edited by Gamma Ray: 16 September 2012 - 11:53 AM

Was This Post Helpful? 1
  • +
  • -

#4 alzy101  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 22-May 12

Re: [C#] Messiest Code I've Written

Posted 19 September 2012 - 08:22 AM

none of these codes are messy at all o.o maybe slightly but c'mon -.-
Was This Post Helpful? 0
  • +
  • -

#5 Sho Ke  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 107
  • View blog
  • Posts: 246
  • Joined: 13-October 11

Re: [C#] Messiest Code I've Written

Posted 19 September 2012 - 08:53 AM

Speaking of messy code..
This is something I made up my first few weeks of learning Javascript..
(only the javascript portion of the code. I made a div look like command prompt,
which took a bunch of css)
function readResponse() {
//Checks to see if player is alive. if dead, game will not run
if (hp>= 1)


// HELP
if (document.gameForm.userResponse.value == "help") { document.gameForm.gameOutput1.value = help1; document.gameForm.gameOutput2.value = help2; }
// END GAME
 if (document.gameForm.userResponse.value == "die") { document.gameForm.gameOutput1.value = die1; document.gameForm.gameOutput2.value = die2; document.gameForm.gameOutput3.value = die3; document.gameForm.gameOutput4.value = die4; hp = 0 } 
 if (document.gameForm.userResponse.value == "Tanner") {location.href = '<link removed>'; }
 //Intro
 if (document.gameForm.hideState.value == "0")
			if (document.gameForm.userResponse.value == "start" ) { document.gameForm.gameOutput1.value = start1; document.gameForm.gameOutput2.value = start2; document.gameForm.gameOutput3.value = start3; document.gameForm.gameOutput4.value = start4; document.gameForm.hideState.value = "1"; }
			else if (document.gameForm.userResponse.value == "look up" ) {document.gameForm.gameOutput1.value = lookupOne0; document.gameForm.gameOutput2.value = lookupTwo0;}
			else if (document.gameForm.userResponse.value == "look north") {document.forms[0].gameOutput1.value = looknorthOne0; document.forms[0].gameOutput2.value = looknorthTwo0;}
			else if (document.gameForm.userResponse.value == "look east") {document.forms[0].gameOutput1.value = lookeastOne0; document.forms[0].gameOutput2.value = lookeastTwo0;}
			else if (document.gameForm.userResponse.value == "look south") {document.forms[0].gameOutput1.value = looksouthOne0; document.forms[0].gameOutput2.value = looksouthTwo0;}
			else if (document.gameForm.userResponse.value == "look west") {document.forms[0].gameOutput1.value = lookwestOne0; document.forms[0].gameOutput2.value = lookwestTwo0;}
			else if (document.gameForm.userResponse.value == "look down") {document.forms[0].gameOutput1.value = lookdownOne0; document.forms[0].gameOutput2.value = lookdownTwo0;}


			
else if (document.gameForm.userResponse.value == "look") {document.gameForm.gameOutput5.value = "Look at what?"; }
else if (document.gameForm.userResponse.value == "go") {document.gameForm.gameOutput5.value = "Go where?"; }
	else {document.gameForm.gameOutput5.value = "That is not a verb I recognize."; }
		document.gameForm.userResponse.value = "";				
if (hp <= 0) {document.gameForm.userResponse.value = "YOU ARE DEAD."; }	
		}




And the "data" file

//Stats
var hp = 10 ;

//GLOBALS
var look = "look ";
var help1 = "Commands: go + direction, look + direction or object, die," ;
var help2 = "pick up object, attack \"enemy\" with \"weapon\", flee" ;
var die1 = "You decide life is no longer worth living and begin looking";
var die2 = "for a way to die. After about an hour, you see a rattlesnake.";
var die3 = "You slowly approach it and extend your hand to its head.";
var die4 = "As it bites you, you wonder why you did such an idiotic thing.";



var house1 = "";
var house2 = "";
var house3 = "";
var house4 = "";
//GAME STATE ZERO
var lookupOne0 = "You don't see anything because you haven't started the game" ;
var lookupTwo0 = "yet!" ;

var looknorthOne0 = "You don't see anything because you haven't started the game" ;
var looknorthTwo0 = "yet!" ;

var lookeastOne0 = "You don't see anything because you haven't started the game" ;
var lookeastTwo0 = "yet!" ;

var looksouthOne0 = "You don't see anything because you haven't started the game" ;
var looksouthTwo0 = "yet!" ;

var lookwestOne0 = "You don't see anything because you haven't started the game" ;
var lookwestTwo0 = "yet!" ;

var lookdownOne0 = "You don't see anything because you haven't started the game" ;
var lookdownTwo0 = "yet!" ;

var start1 = "You wake up in your house. You notice a bookshelf with a few"
var start2 = "objects on the shelves, a pantry, an ice chest, and a statue of a";
var start3 = "Knight. There are no other objects of interest. To the north is ";
var start4 = "an unlocked door.";

//GAME STATE ONE

//GAME STATE ONE --- Waking up in your house for the first time.



Oh yeah.. And the only thing you could do in that game was look around and kill yourself.. :D/>

This post has been edited by Sho Ke: 09 January 2014 - 07:23 PM

Was This Post Helpful? 0
  • +
  • -

#6 Gamma Ray  Icon User is offline

  • D.I.C Head

Reputation: 12
  • View blog
  • Posts: 136
  • Joined: 24-September 10

Re: [C#] Messiest Code I've Written

Posted 20 September 2012 - 10:14 AM

View PostSho Ke, on 19 September 2012 - 08:53 AM, said:

Oh yeah.. And the only thing you could do in that game was look around and kill yourself.. :D


Seems like a reasonable thing one would do after looking at that code. :)

(That joke grew inside me, couldn't resist posting...)
Was This Post Helpful? 2
  • +
  • -

Page 1 of 1