Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your help!

We need 1 more developer from Canada and 12 more from Australia to help us complete a research survey.

Support our site by taking a quick sponsored survey and win a chance at a $50 Amazon gift card. Click here to get started!


fastcall22

Member Since 04 Feb 2008
Offline Last Active Today, 12:23 AM

#5232255 An Open World Idea

Posted by fastcall22 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 fastcall22 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 fastcall22 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 fastcall22 on 25 May 2015 - 01:35 PM

Nope nope nope.


#5228275 Can I do MIMD on SIMD architecture?

Posted by fastcall22 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 fastcall22 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
	TextRenderTarget->DrawTextW(
		Text.c_str(),
		wcslen(Text.c_str()),


... What.


#5227578 Small C++11 regex question

Posted by fastcall22 on 06 May 2015 - 02:14 PM

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

"\\d{2}:\\d{2}:\\d{2}"


#5226543 Java Challange

Posted by fastcall22 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 fastcall22 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
	} ?>
</div>
var update_stats = function() {
    $.ajax('stats.php')
    .success(function(html) {
        document.getElementById('playerStats').innerHTML = html;
    });
};

btnMove.onclick = function() {
    $.ajax({
        url: 'move.php',
        method: 'POST',
        data: {
            direction: 'UP'
        }
    }).success(function(){
        update_stats();
    });
};

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 fastcall22 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 fastcall22 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 fastcall22 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.


Client: 
# 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'
		data:
			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'
			return

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

	return defer.promise()


disable_ui()
do_update()
.always ->
	enable_ui()
	return
.done (payload) ->
	update_game(payload)
	return
.fail (error) ->
	alert "An error occured\n#{error}"
	return
Server:
<?php
# 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();
}
set_error_handler('hook_error');
*/
 
$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 :​(
EDIT2: OMG
EDIT3: IPS PLS
EDIT4: FINE, I'LL USE PASTEBIN
EDIT5: NEVERMIND, I'LL JUST STICK IT TO THE MAN



#5223786 Rate my Game Loop

Posted by fastcall22 on 16 April 2015 - 02:17 PM

Rating:
★★☆☆☆ (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.


#5223732 FastCall Is Alll

Posted by fastcall22 on 16 April 2015 - 11:06 AM

omg dsm-senpai noticed me ohmy.png

It was written in response to dsm's affection to trigraphs. I figured, why stop at trigraphs? Here's teh code. There's still room for "improvement," but whatever:

http://ideone.com/1lnIcm
#include <iostream>
#include <vector>
#include <sstream>
#include <algorithm>
#include <string>
#include <iterator>
 
#define mod %
#define div /
#define mul *
#define add +
#define sub -
#define insert <<
#define extract >>
#define shl <<
#define shr >>
#define bor |
#define band &
#define bxor ^
#define bnot ~
#define ptr *
#define assign =
#define equal_to ==
#define addr_of  &
#define open_paren (
#define open_bracket [
#define open_brace {
#define open_angle <
#define less_than <
#define close_paren )
#define close_bracket ]
#define close_brace }
#define close_angle >
#define greater_than >
#define comma ,
#define call ()
#define member .
 
#define block_begin {
#define block_end }
#define stop ;
 
int main open_paren int argc comma char ptr ptr argv close_paren
block_begin
	using namespace std stop
	string line stop
 
	while open_paren
		cout insert "\n> " insert flush and
		getline open_paren cin comma line close_paren close_paren
	block_begin
		istringstream stream open_paren line close_paren stop
		auto vec assign vector open_angle int close_angle open_paren
			istream_iterator open_angle int close_angle open_paren stream close_paren comma
			istream_iterator open_angle int close_angle call
		close_paren stop
 
		sort open_paren
			vec member begin call comma
			vec member end call
		close_paren stop
 
		cout insert '[' stop
		if open_paren vec member size call close_paren block_begin
			copy open_paren
				vec member begin call comma
				vec member end call sub 1 comma
				ostream_iterator open_angle int close_angle open_paren
					cout comma ", "
				close_paren
			close_paren stop
			cout insert vec member back call stop
		block_end
		cout insert ']' insert endl stop
	block_end
block_end
Sample run:
> 9 4 -3 4 0 7 8
[-3, 0, 4, 4, 7, 8, 9]

> -3 4 7 10 9 6
[-3, 4, 6, 7, 9, 10]

> 4 3 1 5 7
[1, 3, 4, 5, 7]



#5223303 Constant Buffers Disappearing

Posted by fastcall22 on 14 April 2015 - 07:59 PM

How are you setting up your constant buffer? Are you filling it with DeviceContext.MapSubresource and are you attaching it to the shader via DeviceContext.VertexShader.SetConstantBuffer?
Is it disappearing randomly during the program, or before the very first frame?




PARTNERS