• 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
Plethora

Curiosity about compiler warnings

9 posts in this topic

So I've read before that its general good practice to take care of compiler warnings whenever possible and that makes sense to me and I do so as much as I can, but I run into some of them every so often that don't really make sense to me.  Such as:

 

conversion from 'int' to 'float', possible loss of data

 

Firstly, how would I lose data if I'm going from int to float?  Obviously if I was going from float to int I would potentially lose data and that wouldn't be good generally speaking, but from int to float? 

 

Secondly, the line of code referred to in my current program is taking the return value of one function (not even my function, from a library I'm using) and applying it as a parameter in another function (also not one of mine).  Would it be considered good practice to explicitly re-cast the int as a float and then use it as a parameter in this case?

0

Share this post


Link to post
Share on other sites

In general, is it considered good programming practice to eliminate warning generating code at all times even when you're pretty damned sure there wouldn't ever be a problem with it?

0

Share this post


Link to post
Share on other sites

Well, the line of code in question is referring the the X'th pixel of a 32x32 image, so I think in this case I'm safe since if it falls in the range where there could be a problem... well there would be far more serious issues with my code if that happens, lol.

 

But point taken on the general case, thanks for the answers all.  :)

0

Share this post


Link to post
Share on other sites

So I've read before that its general good practice to take care of compiler warnings whenever possible

On a few of the commercial projects I've worked on, they've enabled the highest level of warnings, and also enabled "treat warnings as errors" so that your code won't build if there's any errors.
They've also then had a system where you cannot commit your code into the central repository if it doesn't build, which forces people to always fix their warnings immediately wink.png

2

Share this post


Link to post
Share on other sites

In general, is it considered good programming practice to eliminate warning generating code at all times even when you're pretty damned sure there wouldn't ever be a problem with it?

 

The reasons warnings exist is to let you know that you've done something potentially problematic. The compiler doesn't know if you did it intentionally or not. The warning gives you the opportunity to clarify. If it *is* intentional, then you can add a cast or whatever else you need to do so that the compiler, and other programmers, can understand it's what you wanted to do. If it was a mistake, you can change the offending code to something else. Fixing warnings is considered good practice because it makes your code easier to reason about. But you shouldn't do so blindly. You have to always be aware of the parameters surrounding the offending code. Things like truncation, signed/unsigned comparisons, and so on can come back and bite you later on down the road even if you are using it intentionally, especially as the code base evolves and lines are added and removed.

1

Share this post


Link to post
Share on other sites

A long time ago as I was writing a graph drawing class and wanted some method to test it, I ended up writing a method to plot precision ranges for floating point numbers. Here are the linear and logarithmic displays of 32, 64 and 80 bit floating point numbers graphed exponent vs minimum precision (step). I find them useful to look at every now and then.

 

[attachment=14499:fpPrecisionLin.jpg]

[attachment=14500:fpPrecisionLog.jpg]

2

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