• 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
Christoher Randin

How is my programming format

8 posts in this topic

I tend to be a bit picky as to how I format my code. Just wondering if all this is necessary and also if the some what obvious functions like ApplyGravityForce() and HandleEvents() are even worth while?
class TwoDPlatformController ( MonoBehaviour ): 	
	public walkSpeed   as single     = 6.0F
	public runSpeed	   as single     = 10.0F
	public jumpSpeed   as single     = 8.0F
	public gravity     as single     = 20.0F
	public doubleJump  as bool       = true
	public midAirJumps as int 		 = 2
	
	private moveDirection as Vector3 = Vector3.zero
	private curNumJump as int        = 1
	private controller as CharacterController
	
	def Update():
		PlayerMovement()
		HandleEvents()
		
	def PlayerMovement ():
		controller = GetComponent(CharacterController)
		
		// While character is grounded allow to jump and horizontal movement
		// Player is restricted in jump movement.  One way jump if double jump disabled
		if controller.isGrounded:
			moveDirection = Vector3( -1 * Input.GetAxis('Horizontal')*walkSpeed, 0, 0 )
			SingleJump()
		
		//Player is in the air
		else:
			ExtraJump()
			
				
		ApplyGravityForce()
		
		controller.Move( moveDirection * Time.deltaTime )
		
	def SingleJump ():
	// Immediately present number of allowed mid air jumps when landed
	// Allow player to jump
		
		curNumJump = 1	
		if Input.GetButton( 'Jump' ) or Input.GetKeyDown( 'w' ):
			moveDirection.y = jumpSpeed
			
	def ExtraJump ():
	// Allow player the capability to jump multiple times in mid air
	//  Number of times is based on 'midAirJumps'
	//  Once limit is reach player must land before jumping again
	// When jumping horizontal movement is unlocked for that jump then it will be locked again
	
		if (Input.GetButtonDown( 'Jump' ) or Input.GetKeyDown( 'w' )) and doubleJump:
			//Player has not met his extra jumping limit
			if curNumJump < midAirJumps:
				moveDirection = Vector3( -1 * Input.GetAxis('Horizontal')*walkSpeed, 0, 0 )
				moveDirection.y = jumpSpeed
				curNumJump += 1	
	def ApplyGravityForce ():
		moveDirection.y -= ( gravity * Time.deltaTime )
		
	def HandleEvents ():
	// Events taken place are of action types: shooting, special attacks, interactable object, etc
		pass
1

Share this post


Link to post
Share on other sites

Hi Cdrandin,

 

First of all let me tell you I don't program unity but do program python, c#, c++, etc. Looking at the format I personally think it looks really clean. Only thing I would change myself (if possible) is put the description of the function above the function. Also I am missing a simple outline for the class (meaning a bit of comments explaining what this class is for).

 

As for the rest of the code I think it looks pretty nice.

 

With kind regards,

 

StaticCUbe

2

Share this post


Link to post
Share on other sites

I'm not personally for spaces before or after brackets, but at a high level I find the code to be actually readable. The comments are useful and relevant, it's clean. Maybe try and be a bit more consistent with newlines.

1

Share this post


Link to post
Share on other sites

Looks good, I would however recommend learning something more powerful than VB if you expect to make responsive high paced games that those of us with older computers (You know the majority of your potential players) can play.  Yes the obvious functions are always better to have.

Edited by Dan Mayor
2

Share this post


Link to post
Share on other sites
Looks good, I would however recommend learning something more powerful than VB if you expect to make responsive high paced games that those of us with older computers (You know the majority of your potential players) can play. Yes the obvious functions are always better to have.
That's not VB, I think it's Boo. Edited by Mussi
1

Share this post


Link to post
Share on other sites
Looks good, I would however recommend learning something more powerful than VB if you expect to make responsive high paced games that those of us with older computers (You know the majority of your potential players) can play. Yes the obvious functions are always better to have.
That's not VB, I think it's Boo.

 

Well that might just negate my comment.  If it's a scripting language particular to the engine than it probably is among the best performance you would get with the entire kit.  Just noticed the lack of ; and {} which immediately makes me thing VB or even worse Python :-o

1

Share this post


Link to post
Share on other sites
<blockquote class="ipsBlockquote" data-author="Dan Mayor" data-cid="5018658"><p><br /></p><blockquote class="ipsBlockquote" data-author="Mussi" data-cid="5018581"><p><br /></p><blockquote class="ipsBlockquote" data-author="Dan Mayor" data-cid="5018578"><p>Looks good, I would however recommend learning something more powerful than VB if you expect to make responsive high paced games that those of us with older computers (You know the majority of your potential players) can play. Yes the obvious functions are always better to have.</p></blockquote>That's not VB, I think it's Boo.<p><br /></p></blockquote>&nbsp;<br />Well that might just negate my comment. &nbsp;If it's a scripting language particular to the engine than it probably is among the best performance you would get with the entire kit. &nbsp;Just noticed the lack of ; and {} which immediately makes me thing VB or even worse Python :-o<br />&nbsp;<br /><p><br /></p></blockquote><br />Both VB.Net and IronPython runs pretty darn fast (performance is comparable to what you get with normal C# code), and that is indeed Boo (Which is a .Net language similar to Python). (The only really slow Python implementation i can think of is CPython, but even that is fast enough if you got an engine that does the heavy lifting for you)<br /><br />Also, what do you have against Python ? you are probably the first programmer i've seen who say that python is worse than VB (I don't think it is even possible for a language to be worse than VB, (COBOL or Brainfuck might possibly manage it, but even that is debatable)
-1

Share this post


Link to post
Share on other sites

I personally think it looks clean.  I used to smash all of my code into one place (e.g. all logic in the Update() function in Unity) and use "folding comments" to organize it, but now I'm starting to prefer separating them into functions and applying that to all my latest code.

 

I'm not sure if this actually works with Boo, but if you're using the text editor that comes with Unity, called UniSciTE, then it allows you to make "folding comments" like so:

 

 

//{Movement:
//Movement code goes here
//}
//{Jumping:
//Jumping code goes here
//}

These are like 'regions'.  I'm not sure if regions are applicable to other languages/IDEs, because I've only used them in Visual Studio C#, but I know they don't work in UniSciTE.

Anyway, they make it so that you can fold the selection, and hide everything but the first comment with the starting brace in it, like "//Jumping:"

 

I think there are a lot of people who are against the idea of folding up your code with regions (or "folding comments"), but I just wanted to let you know about them if you wanted to use them.  They're pretty much the only way to fold stuff up in UniSciTE manually, without that something being a function, class, etc.

 

Anyway, as I said, you might not want to use this technique and it might not even work with Boo, but too bad because knowing about it is already taking up space in your brain!

0

Share this post


Link to post
Share on other sites

Very nice but comment your functions, 6 months from now you wont remember what you wrote so u need to leave your self notes or someone else notes.

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