Saving peoples progress on flash games onto a site - php

I know there are sites out there when you log on to their account they can play swf games or otherwise flash games on the site so whenever they go to another computer they can continue their progress without restarting just by logging onto their account.
I would like to know how they do this. So I can added it to my site. I honestly have no clue where to start to learn this. Any help leading me to the right direction. Or if you can give me some code. I would appreciate it more.

Well, you'd need to create a php/mysql based API for developers. Whatever functions you want them to be able to call in flash to save data, you'll need to code in PHP. You'll also probably have to code something to access the API, in the form of Actionscript code.
It's not something really easy that you could just "add to your site", probably the biggest thing you'd have to do is get developers to integrate it to their games. There's (unfortunately!) no magic self-implementing code which a flash developer can add to their game which has a standard serverside library, for saving data.
You'll probably want to take a look at this tutorial for the basics of how to go about implementing this.

Related

Better way to make chat application?

Currently I'm making a chat application where only admin and users chat, no user-to-user chat . The design is: every chat is stored in database and each 2 seconds user and admin make an AJAX request (to a php file) to see if there is a new chat dialogue, and if there is, pull the data into the textbox. It all seems normal and working good.
Problem is as more user is talking to admin at the same time the AJAX request is becoming a lot, and by testing, the web performance already decreased with only 5 users chatting at the same time. And the input is slow too, every time user press enter they got to enter the data into database first before the admin can read it (and vice versa).
I have been told that using JSON is a recommended way, but I have no idea how to do it, can someone please at least tell me how's the design or flow is going to be if use JSON? Or is there a better way to make it? (by the way, using node.js is currently impossible for my current hosting, so don't put it in suggestion lists, sucks I know).
You should change the AJAX responder phps output to JSON. (you can use the json_encode php function for example.) And you should parse(eval) this in javascript.
I am a bit sceptic. It think It could reduce the network usage by more than 50%.
Maybe you can try a message queue, like 0mq or rabbitmq.
There are a lot of chat examples around.

HTML5 Multiplayer Browser Game

I am having difficulty with one part of my simple HTML5 game. I've decided to make it multiplayer. How do I go about making a change to the position of a div on my screen visible on the other users screen?
It's a two player game, with a simple move left and move right function to move divs. My first thought was to use sessions, but when I got to writing some code, I realised I knew nothing, so I headed over to CSS Tricks (couldn't find anything for my use), headed over to Dave Walsh (nothing listed) and couldn't find anything of use on Google, no matter what search term I put in.
I know this is possible with modern browsers as I've seen it done in a lot of games online now, however I'm baffled as to how it's done.
Any answer with some links would be greatly appreciated.
I think you may be interested in this article. It is an example of making online multiplayer game with NodeJS. It reveals some concepts as well as gives the actual code.
You have 2 possibilities within the simple ones:
1- refresh automatically the page of both users periodically - not very fancy
2- use ajax to query the server of a possible move from the other player
The option 2 would work well if it is a turn-by-turn game. In case of online game, I think you would need much more complex server technology like Node.js for instance.

Setting up an online server database and code my android native app to interact with it

Im developing a very simple native Android App containing a simple Main Menu with the Today, Yesterday, This Week, This Month and Search by Date options.
(I bought the lynda course: "Building Android and iOS Apps with Dreamweaver" with HTML5 and with the design and functionality of the app im not having too much trouble.)
What i entend with this app is this: i will write famous people profiles every day (between 1 and 5). So when people click (for example) in the Today option they will access to the profiles list that i have created for today (Yesterday and others is a check on the past written profiles from database).
So imagine that some android user clicked on today and will be presented with 3 profiles options ("Brad Pitt", "Shakira" and "Cristiano Ronaldo"), that i need the app to access my server database to update it (the "Today" profiles).
and finally...
Before the questions i want to say that i have searched on stackoverflow and found very similar answers, but im a novice on programming and when i'm reading the answers they can differ so much that i got confused going link on link documentation.
The Questions:
I want to create somekind of method that i could have a template with different profiles (Singer, Politician, Soccer Player) and click on somekind of button to start a new profile/article with Born Date, Occupation, Nationality, Biography and etc. Its this possible? How can i do it and in wich programming language?
What kind of server and what kind of database do i have to create and how to configure it to send the info to my app?
There is any server specifications that i must have for this to work the smoother and easiest possible? For this issue price is not a problem.
What kind of code should i write on my app so that it could get the "3 profiles update for today" from my website?
Its possible to show me some code example that would work with this simple step in my app of selectiong "Today" button on main menu and the app check for new profiles for today and present the user as an option? Because if i had this bit of code i could understand better how to do the rest with the profile details on the "Brad Pitt" option for example.
Hope you understood my questions. Thanks in advance. Have a nice day
Assuming that you're using the Phonegap Framework to develop your application, I would do it like so:
First of all get a Server/Webspace capable of running PHP Scripts and a MySQL Database.
You also have to rethink the way these applications work, for example you can't
configure it to send the info to my app
You need a Server Side Script (i would choose PHP for this, it's easy to learn and available on almost every Server). This PHP Script then queries your MySQL Database where all the information about the people is stored. On thing to remember is that your Clients will poll the server and request the content, you're not actively sending anything to Clients unless requested, that's just the way how HTTP works. The interface your Script is providing there is called a REST Interface.
Have a look at the link, it explains everything pretty good. Your output format should be JSON this makes it really nice to work with in the Client App later on. To do things like "what was posted today?" Have a look at how SQL Queries work and implement it in your Script.
Now for the client you can access this data by using JavaScript, most likely jQuery to simplify everything a bit. Use the jQuery $.getJSON function to access the data provided by your REST Interface. Now you can use basic jQuery to wrap this data up with HTML to present it to the user. I know that this is not "example code" or anything you requested, but it should point you into the right direction on how to achieve something like you want to do. Just do a google search for all the keywords listed above and keep reading about it, then you should be able to build a app like that.

Appmobi Codeigniter and Facebook SDK JavaScript vs PHP

Ok, this isn't going to be the best quality question without a doubt. But I am looking for advice mostly on how to handle the next phase of an app I am developing. This is my first app in appmobi so things with it are a bit confusing to me still.
So generally speaking I am very used to working with PHP and sticking to browser based development. With that most of what I want to do with Facebook as far as the API's go for the graph I have done using the PHP FB-SDK. If your familiar with Appmobi then you know php is out well directly at least.
This app I am making, I have it working fine with everything else I am doing. I'm communicating with my server, people are logging in, people are registering, people are using the server for what its worth. But this Facebook bit has me stumpped. I want to offer facebook as a means of login/registration for my app, I want to post to facebook from my app pending a user approves it, and a handful of other things. But I dunno the best way to approach this through the app as its all static html based pages and javascript thus far.
So I am hoping someone will read through this all, and hopefully a handful of you that do, will know some means of doing what I want to do, Im not looking for someone to drop me a pile of code and give me the answer (nice as that would be). No I am just simply looking for what I should do to handle this between all the layers mentioned here to make this work. So I can start building this piece up.
Regarding Facebook, appMobi has recently added a Facebook object to the API you might use to be able to log into Facebook and access the Facebook Graph. You can find the Facebook API documentation here:
http://www.appmobi.com/documentation/jsAPI/facebook/index.html
There is a supporting document illustrating how to set up things on Facebook's side that can be found here:
http://www.appmobi.com/documentation/index.php?DOC=FACEBOOK_INTEGRATION
I'll do my best to post some sample code as well. I'm kind of working through the exact same thing.

Integrating a JavaScript chat in a php web based game

Is it possible to implement a JavaScript plugin/app in a web text based game? if it is, how is this done. I don't really need the codes. All I want is the functionality. Basically, I want a player in the game to talk to another player in the same game. Like if he(player) enters a room, I want him to see a player and communicate with him or her. Remember, it is chatting with another player, not another user.
Also, I want the php code used to integrate this app onto the site.
WebSockets are part of HTML5 and fit in my webbased game just neatly. There is a full guide on http://net.tutsplus.com/tutorials/javascript-ajax/start-using-html5-websockets-today/
you can use long polling with js/jquery ajax calls to the php scripts and the database (or files) to make a chat like program
Try searching for some open/free libraries that you can integrate with your game if you don't want to spend time implementing the chat part yourself. I just found this - https://blueimp.net/ajax/ but I have not used it, so you may want to take a look at the features and if it works for you.

Categories