Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 04 Feb 2008
Offline Last Active Yesterday, 11:14 PM

#5235160 Texture DXGI_FORMAT problem

Posted by on 16 June 2015 - 11:36 AM

According to Important changes from Direct3D 9 to Direct3D 11, support for 24bpp textures no longer exists.

Promote to 32bpp and use DXGI_FORMAT_R8G8B8A8_UNORM.

#5234161 Simulating Typing in C

Posted by on 10 June 2015 - 05:03 PM

I would highly recommend using std::string, [it's much safer]

[Why] C and not [C++]?

[C++ nit-picking]

[C++ nit-picking]

"Why are you using C strings in your C program? You should use C++ strings in a C++ program instead." Ugh. OP is learning C, not C++.

How about we suggest that he use Java instead? Java is far safer than C++, because exceptions, virtual environment, and other fun stuff.


#5232255 An Open World Idea

Posted by on 01 June 2015 - 04:48 PM

... and finding players to get along with is the most crucial thing in the game

Yeah, no. Trying to find a handful of players in 3.806 million sq miles does not sound like fun.

This "idea" of yours is basically just Grand Theft Auto, but in a larger kitty-litter box.

#5232103 signal() : any performance impact ?

Posted by on 01 June 2015 - 12:11 AM

Compared to the OS cleaning up the process, the OS spinning up a new process, and your process restoring it's previous state? Probably negligible.

If you need real-time communication between two processes, try pipes, shared memory, or even logging to a file.

#5231107 C++ tinyDir lib issue

Posted by on 26 May 2015 - 12:55 PM

Why do the first 2 lines appear?

Ignore them.

Technical details:
"." and ".." are symbolic links to the current and parent folders respectively. Think of a tree, for a node, these "child nodes" are pointers to the current node and it's parent node. It's what makes path names such as "./omg/../../wtf/bbq/your_mom" possible.

#5230881 OpenGL vs DirectX

Posted by on 25 May 2015 - 01:35 PM

Nope nope nope.

#5228275 Can I do MIMD on SIMD architecture?

Posted by on 10 May 2015 - 04:03 PM

Can it be done with some sort of hack?

No, but you can use a 1, in this case:

(4*1) + 4
(4*6) + 1

#5228154 D2DFontX 1.0 Released Today!

Posted by on 09 May 2015 - 12:57 PM

void D2DFontX::RenderText(std::wstring text) {
	//Create our string
	std::wostringstream printString;
	printString << text;
	Text = printString.str(); // (std::wstring D2DFontX::Text)

	//Draw the Text

... What.

#5227578 Small C++11 regex question

Posted by on 06 May 2015 - 02:14 PM

Additionally, double check that you are properly escaping your backslashes:


#5226543 Java Challange

Posted by on 30 April 2015 - 12:30 PM

public class Wat {
	public static void main(String[] args) {
		CubicRootChallenge.checkCubicRoot(new BigInteger("1"));
		System.out.println("YOU WIN!");

#5225326 Confused. Can I use PHP to make a game?

Posted by on 24 April 2015 - 02:52 PM

Thanks for responding. If you don't mind, could you explain what's going on here?

It looks like you're using more than just JavaScript and PHP here? I really want to stick to HTML (structure the page), CSS (make it look nice), PHP (perform server-side operations), and maybe JavaScript (possibly improve client interface), but nothing else. I'm pretty familiar with HTML and CSS at this point though.

Ah, sorry if I have confused you. The language I use here is coffeescript, which is a language that compiles into javascript. The compiled javascript of the code I posted is here: http://pastebin.com/0di9bsVs.

So, here's whats going on.
$.ajax() queues a POST request (not unlike submitting a HTML form element) to be sent via XHR in the background.
.success and .error chains respective callbacks to be executed when the request completes. We use an additional deferred object to encapsulate all server errors, decoding errors (malformed json), and any application errors:

Bad data or server error: ajax.error() -> deferred.reject with HTTP-error code or jQuery parsing error
Good data, success=false: ajax.success() -> deferred.reject with application error message
Good data, success=true: ajax.success() -> deferred.resolve with payload data

From here we return the deferred object which can then be act upon further, by chaining .done (resolve) and .fail (reject) callbacks to run respective game code and rebuild the page with state.

Note: This is for a responsive game.

For something like partial-page refreshes, you could do something like the following:
<?php # stats.php
include "game.php";

$player = get_player(); 
$stats = $player->stats;

<div class="stats"><?php
	foreach ( $stats as $name => $value ) { ?>
		<div class="stat"><?=$name?></div>
		<div class="value"><?=$value?></div><?php
	} ?>
var update_stats = function() {
    .success(function(html) {
        document.getElementById('playerStats').innerHTML = html;

btnMove.onclick = function() {
        url: 'move.php',
        method: 'POST',
        data: {
            direction: 'UP'

Pardon me, but I'll try to interpret the code. It seems like at the surface, you're still using the $_POST method to talk to the server. How is this much different from my current implementation (I'm not using JavaScript at the moment, just PHP)? Perhaps I'll understand after you explain it.

It's not any different at all. smile.png
PHP is a standard process like everything else: All communication is done through the stdin, stdout, and stderr handles. Upon each request, $_POST is auto-magically constructed from stdin, and $_GET is auto-magically constructed with CGI variables from apache. (PHP's environment variables are inherited and setup by the apache process and contains standard CGI variables like DOCUMENT_ROOT, REQUEST_URI and et al.)

#5225275 Confused. Can I use PHP to make a game?

Posted by on 24 April 2015 - 12:49 PM

If you are interested in the web why PHP?
Since you are going to be using Javascript anyway, why not pick one of the many html5/javascript game engines?
You can use PHP, but there are better options today: local storage and cloud sync.

Local storage and cloud sync are not appropriate replacements for server back-ends. You could use local storage, if the game runs locally and doesn't require communicating with anybody else, including the game's server.
If you're looking for alternative, more responsive back-ends, then look into using websockets with a nodejs server or separate php process dedicated to listening to websockets on a separate port.

#5225262 Confused. Can I use PHP to make a game?

Posted by on 24 April 2015 - 12:21 PM

Right. That's why I need a webhost that supports PHP.

Not necessarily. Well, you'll need one once you've finished your game. smile.png

Until then, you may want to consider running a PHP server directly from your machine using EasyPHP or run a full-fledged web server in a virtual machine with Ubuntu Server or some other Linux distro.

#5225258 Confused. Can I use PHP to make a game?

Posted by on 24 April 2015 - 12:05 PM

I'm not sure how I can use Javascript to communicate with the server in any other way.

Requests can be done with XHR and you can use a cross-browser library such as jQuery, AngularJS, or some other lightweight XHR library. Async processes are a pain in Javascript, since you can only nest async functions, but Promises make things a bit better.

# sample.coffee
# for the compiled javascript, see: http://pastebin.com/0di9bsVs
game_state =
	player_id: null
	last_update_ms: 0
	score: 0

do_update = ->
	defer = $.Deferred()

	$.ajax # nake XHR request
		url: '/update.php'
		method: 'POST'
		dataType: 'JSON'
			last_update: game_state.last_update_ms
			score: game_state.score
	.success (response) ->
		if not (response and response.success)
			defer.reject response.message or 'Unknown error occured'

		defer.resolve response.payload
	.error (response,code) ->
		defer.reject "Server returned #{code}"

	return defer.promise()

.always ->
.done (payload) ->
.fail (error) ->
	alert "An error occured\n#{error}"
# update.php
$response = [
        'success' => false,
        'message' => null,
        'payload' => null
# capture PHP errors and warnings, if desired
function hook_error() {
        global $response;
        $response['debug'][] = func_get_args();
$request = $_POST; # or json_decode php:​//input
try {
        # fill sample data
        $game_data = Game::update();
        $response['success'] = true;
        $response['payload'] = $game_data;
} catch ( Exception $ex ) {
        $response['message'] = $ex->getMessage();
header('Content-Type: application/json');
print json_encode($response);
EDIT: Stupid editor ate my post :​(

#5223786 Rate my Game Loop

Posted by on 16 April 2015 - 02:17 PM

★★☆☆☆ (2 of 5 stars)

Does not handle the spiral of death.
Would not recommend stepping time with programmer again.


In addition to what others have said, you may want to consider the case when the simulation can't keep up and must sacrifice updates to keep the simulation going. Otherwise, the simulation will grind to a halt.