• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
RLS0812

What Happens When I Program Before Coffee

9 posts in this topic

 Quite often I will start coding something when I am not fully awake, and can end up with some interesting results.

 Here is a code test I was working on some time ago - looking at it now, about 60% of the code is redundant.

<html>
<?php
class reasource{
#stone
   public $basic_stone = 0;
   public $building_stone = 0;
   public $sturdy_stone = 0;
   public $reinforced_stone = 0;
   public $fancy_stone = 0;
#wood
   public $rough_lumber = 0;
   public $smooth_lumber = 0;
   public $plank = 0;
   public $wooden_dowl = 0;
   public $wooden_strip = 0;
   public $fine_wooden_strip = 0;
   public $wooden_rod = 0;   
#food
   public $food_ration = 100;
   public $animal_feed = 0;
#magic
   public $red_energy_rune = 0;
   public $blue_energy_rune = 0;
   public $green_energy_rune = 0;
   public $black_energy_rune = 0;
   public $fine_oil = 0;
   public $raw_wool = 0;
   public $novic_battle_wand = 0;
   public $journeyman_battle_wand = 0;
   public $expert_battle_wand = 0;
#military
   public $armor_plate = 0;
   public $enchanted_armor_plate = 0;
   public $sword = 0;
   public $pike = 0;
   public $bow = 0;
   public $bow_string = 0;
   public $horse = 0;
#researcher
   public $paper = 0;
   public $ink = 0;
#engineer
   public $raw_iron = 0;
   public $coal_chunks = 0;
   public $iron_bar = 0;
   public $enchanted_iron_bar = 0;
   public $taned_leather = 0;
#spy
   public $dagger = 0;
   public $leather_armor = 0;
   public $poison = 0;
   public $sapper_tools = 0;
   }
class army{
#mod array(attack,defence)
   public $pit_fighter = 0;
   public $mod_pit_fighter = array(1,1);
   public $swordsman = 0;
   public $mod_swordsman = array(3,1);
   public $armored_swordsman = 0;
   public $mod_armored_swordsman = array(3,3);
   public $knight = 0;
   public $mod_knight = array(5,5);
   public $bowman = 0;
   public $mod_bowman = array(4,1);
   public $pikeman = 0;
   public $mod_pikeman = array(1,4);
   public $catapult = 0;
   public $mod_catapult = array(10,0);
   }
class engineer{
#mod array(modifier)
   public $tinker = 0;
   public $mod_tinker = array(1);
   public $novic_black_smith = 0;
   public $mod_novic_black_smith = array(2);
   public $journeyman_black_smith = 0;
   public $mod_journeyman_black_smith = array(5);
   public $expert_black_smith = 0;
   public $mod_expert_black_smith = array(10);
   public $novic_construction = 0;
   public $mod_novice_construction = array(2);
   public $journeyman_construction = 0;
   public $mod_journeyman_construction = array(5);
   public $expert_construction = 0;
   public $mod_expert_construction = array(10);
   }
class wizard{
#mod array(modifier)
   public $hedge_mage = 0;
   public $mod_hedge_mage = array(1);
   public $novic_red_mage = 0;
   public $mod_novic_mage = array(2);
   public $journeyman_mage = 0;
   public $mod_journeyman_mage = array(5);
   public $expert_mage = 0;
   public $mod_expert_mage = array(10);
   
   }
class spy{
#mod array(modifier)
   public $sneak = 0;
   public $mod_sneak = array(1);
   public $novic_spy = 0;
   public $mod_novic_spy = array(2);
   public $journeyman_spy = 0;
   public $mod_journeyman_spy = array(5);
   public $expert_spy = 0;
   public $mod_expert_spy = array(10);
   }
   
class buildings{
#mod array(attack,defence,land usage,modifier)
     public $village_house = 5;
	 public $mod_village_house = array(0,0,5,15);
	 public $dorm = 0;
	 public $mod_dorm = array(0,0,10,50);
	 public $apartment = 0;
	 public $mod_apartment = array(0,0,20,200);
	 public $barrack = 0;
	 public $mod_barrack = array(0,0,10,10);
	 public $army_base = 0;
	 public $mod_army_base = array(0,0,25,100);
     public $tower = 0;
	 public $mod_tower = array(0,0,10,10);
	 public $mage_tower = 0;
	 public $mod_mage_tower = array(0,0,25,100);
	 public $den = 0;
	 public $mod_den = array(0,0,10,10);
	 public $large_den = 0;
	 public $mod_large_den = array(0,0,25,100);
	 public $foundry = 0;
	 public $mod_foundry = array(0,0,10,10);
	 public $large_foundry = 0;
	 public $mod_large_foundry = array(0,0,25,30);
	 public $factory = 0;
	 public $mod_factory = array(0,0,10,10);
	 public $large_factory = 0;
	 public $mod_large_factory = array(0,0,25,30);
	 public $wall = 0;
	 public $mod_wall = array(0,1,5,0);
	 public $tall_wall = 0;
	 public $mod_tall_wall = array(0,5,10,0);
	 public $great_wall = 0;
	 public $mod_great_wall = array(0,12,25,0);
	 public $training_camp = 0;
	 public $mod_training_camp = array(0,0,10,10);
	 public $boot_camp = 0;
	 public $mod_boot_camp = array(0,0,25,30);
	 # functions
	 function get_building_ad(){
	    $x = 
		    ($this->$village_house * $this->$mod_village_house[0]) +
			($this->$dorm * $this->$mod_dorm[0]) +
		    ($this->$apartment * $this->$mod_apartment[0]) +
			($this->$barrack * $this->$mod_barrack[0]) +
			($this->$army_base * $this->$mod_army_base[0]) +
			($this->$tower * $this->$mod_tower[0]) +
			($this->$mage_tower * $this->$mod_mage_tower[0]) +
			($this->$den * $this->$mod_den[0]) +
			($this->$large_den * $this->$mod_large_den[0]) +
			($this->$foundry * $this->$mod_foundry[0]) +
			($this->$large_foundry * $this->$mod_large_foundry[0]) +
			($this->$factory * $this->$mod_factory[0]) +
			($this->$large_factory * $this->$mod_large_factory[0]) +
			($this->$wall * $this->$mod_wall[0]) +
			($this->$tall_wall * $this->$mod_tall_wall[0]) +
			($this->$great_wall * $this->$mod_great_wall[0]) +
			($this->$training_camp * $this->$mod_training_camp[0]) +
			($this->$boot_camp * $this->$mod_boot_camp[0]) ;
        $y =
		    ($this->$village_house * $this->$mod_village_house[1]) +
			($this->$dorm * $this->$mod_dorm[1]) +
		    ($this->$apartment * $this->$mod_apartment[1]) +
			($this->$barrack * $this->$mod_barrack[1]) +
			($this->$army_base * $this->$mod_army_base[1]) +
			($this->$tower * $this->$mod_tower[1]) +
			($this->$mage_tower * $this->$mod_mage_tower[1]) +
			($this->$den * $this->$mod_den[1]) +
			($this->$large_den * $this->$mod_large_den[1]) +
			($this->$foundry * $this->$mod_foundry[1]) +
			($this->$large_foundry * $this->$mod_large_foundry[1]) +
			($this->$factory * $this->$mod_factory[1]) +
			($this->$large_factory * $this->$mod_large_factory[1]) +
			($this->$wall * $this->$mod_wall[1]) +
			($this->$tall_wall * $this->$mod_tall_wall[1]) +
			($this->$great_wall * $this->$mod_great_wall[1]) +
			($this->$training_camp * $this->$mod_training_camp[1]) +
			($this->$boot_camp * $this->$mod_boot_camp[1]) ;
	    return arrray($x,$y);
		}
		function add_building($build,$amount){
		    if ($build == "village_house"){$this->$village_house += $amount;}
			if ($build == "dorm"){$this->$dorm += $amount;}
		    if ($build == "apartment"){$this->$apartment += $amount;}
			if ($build == "barrack"){$this->$barrack += $amount;}
			if ($build == "army_base"){$this->$army_base += $amount;}
			if ($build == "tower"){$this->$tower += $amount;}
			if ($build == "mage_tower"){$this->$mage_tower += $amount;}
			if ($build == "den"){$this->$den += $amount;}
			if ($build == "large_den"){$this->$large_den += $amount;}
			if ($build == "foundry"){$this->$foundry += $amount;}
			if ($build == "large_foundry"){$this->$large_foundry += $amount;}
			if ($build == "factory"){$this->$factory += $amount;}
			if ($build == "large_factory"){$this->$large_factory += $amount;}
			if ($build == "wall"){$this->$wall += $amount;}
			if ($build == "tall_wall"){$this->$tall_wall += $amount;}
			if ($build == "great_wall"){$this->$great_wall += $amount;}
			if ($build == "training_camp"){$this->$training_camp += $amount;}
			if ($build == "boot_camp"){$this->$boot_camp += $amount;}
		}
		function sub_building($build,$amount){
		    if ($build == "village_house"){$this->$village_house = abs($this->$village_house - $amount);}
			if ($build == "dorm"){$this->$dorm = abs($this->$dorm - $amount);}
		    if ($build == "apartment"){$this->$apartment = abs($this->$apartment - $amount);}
			if ($build == "barrack"){$this->$barrack = abs($this->$barrak - $amount);}
			if ($build == "army_base"){$this->$army_base = abs($this->$army_base - $amount);}
			if ($build == "tower"){$this->$tower = abs($this->$tower - $amount);}
			if ($build == "mage_tower"){$this->$mage_tower = abs($this->$mage_tower - $amount);}
			if ($build == "den"){$this->$den = abs($this->$den - $amount);}
			if ($build == "large_den"){$this->$large_den = abs($this->$large_den - $amount);}
			if ($build == "foundry"){$this->$foundry = abs($this->$foundry - $amount);}
			if ($build == "large_foundry"){$this->$large_foundry = abs($this->$large_foundry - $amount);}
			if ($build == "factory"){$this->$factory = abs($this->$factory - $amount);}
			if ($build == "large_factory"){$this->$large_factory = abs($this->$large_factory - $amount);}
			if ($build == "wall"){$this->$wall = abs($this->$$wall - $amount);}
			if ($build == "tall_wall"){$this->$tall_wall = abs($this->$tall_wall - $amount);}
			if ($build == "great_wall"){$this->$great_wall = abs($this->$great_wall - $amount);}
			if ($build == "training_camp"){$this->$training_camp = abs($this->$training_camp - $amount);}
			if ($build == "boot_camp"){$this->$boot_camp = abs($this->$boot_camp - $amount);}
		}
		function get_people_storage(){
		$x =
		    ($this->$village_house * $this->$mod_village_house[3]) +
	        ($this->$dorm * $this->$mod_dorm[3]) +
	        ($this->$apartment * $this->$mod_apartment[3]);
		return $x;
		}
		function get_army_storage(){
		$x =
		   ($this->$barrack * $this->$mod_barrack[3]) +
		   ($this->$army_base * $this->$mod_army_base[3]);
		return $x;
		}
		function get_mage_storage(){
		$x =
		   ($this->$tower * $this->$mod_tower[3]) +
		   ($this->$mage_tower * $this->$mod_mage_tower[3]);
		return $x;
		}
		function get_spy_storage(){
		$x =
		   ($this->$den * $this->$mod_den[3]) +
		   ($this->$large_den = $this->$mod_large_den[3]);
		return $x;
		}
	    }
class events{
   public $attract_villager = 86400;
   public $last_attract_villager = 0;
   public $import = 86400;
   public $last_import = 0;
   # functions
   function set_event_villager(){
   $this->$last_attract_villager = mktime() + $this->$attract_villager ;
   }
   function check_event_villager(){
   if (mktime() > $this->$last_attract_villager){
      return FALSE;
     }
   else{
      return TRUE;
     }
   }
   function set_event_import(){
   $this->$last_import = mktime() + $this->$attract_villager ;
   }
   function check_event_import(){
   if (mktime() > $this->$last_import){
      return FALSE;
     }
   else{
      return TRUE;
     }
   }
   }
   ?>
</html>
Edited by Shippou
1

Share this post


Link to post
Share on other sites

Is it sad that after a few years away from web development, I'm starting to consider writing software in PHP as the real WTF?

0

Share this post


Link to post
Share on other sites

Is it sad that after a few years away from web development, I'm starting to consider writing software in PHP as the real WTF?

 

As opposed to .... ASP.NET? They've had a few cluster***ks themselves.

Edited by Alpha_ProgDes
0

Share this post


Link to post
Share on other sites

 

The joys of writing desktop software, in a high-level language, with a real debugger and profiler hooked into your IDE, is hard to overstate...

 

Or a not-so-high level language such as C++ IMO is much better - just as easy to use once you learn it but much more control.

0

Share this post


Link to post
Share on other sites

 


As opposed to .... ASP.NET? They've had a few cluster***ks themselves.

No, I'm kind of lumping all web technologies in the same boat here.

 

The joys of writing desktop software, in a high-level language, with a real debugger and profiler hooked into your IDE, is hard to overstate...

 

Meh, Python with Django is pretty darn enjoyable, only thing i've found that comes close to being as enjoyable on the desktop side is QT.

 

PHP however is quite awful, it was only a good choice when the only real competior was ASP with VBScript. (The only reason to use it today is because its popular)

Edited by SimonForsman
0

Share this post


Link to post
Share on other sites

99% of all the host sites I have used ( that actually allow API ), have PHP and nothing else.

0

Share this post


Link to post
Share on other sites

99% of all the host sites I have used ( that actually allow API ), have PHP and nothing else.

Pretty much all of them have perl, and CGI scripts (not that those are generally any better choices).

 

If you upgrade to a VPS, you can generally install pretty much whatever you want in the way of scripting languages. Windows servers for ASP.net tend to cost extra, but who'd want that anyway? ;)

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0