Desktop dev needs web dev advice

try{ getFittingBoard(new Topic()); }
catch (Exception e) { postHere() };

Desktop dev needs web dev advice

Postby snctln » Fri Jan 23, 2009 12:50 am

hello everyone. I am looking for some advice/suggestions/recommendations/pointers.

My day job is C++ desktop development, for the past few months I have been doing more and more mobile apps. I am really enjoying android development but I have ran into a slight issue.

I would like to implement an online high score system for my latest game WordWrench but when it comes to web development I have never really bothered to put together too many websites and I don't have a firm grasp on what exactly I should do.

I assume the way this is usually implemented is that the android application makes a web connection to some web page and passes the relevant information as parameters? And then that web page takes those parameters and adds something to a database.

I have done a minimal amount of html work in the past, I did a semi large project in google web toolkit for one of my employers, and I took an intro to sql class in college, but nothing really beyond that.

I was thinking some sort of php/MySql solution, but like I said, I really don't know much about this stuff.

So does anyone have any thoughts on implementing a global online high score feature, both the web and android side of things?
Last edited by snctln on Fri Jan 23, 2009 4:31 pm, edited 1 time in total.
snctln
Freshman
Freshman
 
Posts: 5
Joined: Mon Jan 19, 2009 1:16 am

Top

Postby mortefer » Fri Jan 23, 2009 9:09 am

Not a long time ago a also asked myself about how to implement highscore system. I came to the following solution:
1. you must set up DB to store results (single table would be enough)
2. i though of creating a SOAP Interface so receive connections with high scores (but possibly simple POST/GET requests would do just fine)
3. from your app you open connection to your page (let it be PHP) and pass parameters to it, i.e.:
(http://highscoresite.com/post.php?name= ... SCORE_HERE)
4. Script can check if it should insert those scores to DB (score might be too low or whatever)

To retrieve scores you also request a PHP page (http://highscoresite.com/gethighscores.php) and that can return data in CSV format (user_name, score n user_name, score n user_name, score ....) so it's easier to parse on app side.

As you can see I don't use SOAP here - but hey, this is just a sample explanation :)

Here are the samples of pages.
post.php (assuming parameters are passed as GET request)
Syntax: [ Download ] [ Hide ]
  1. <? 
  2. $name = $_GET['name']; 
  3. $score = $_GET['score']; 
  4.  
  5. mysql_connect(HOST, USER, PASS); 
  6. mysql_select_db(DB_NAME); //connect to mylsq server and select appropriate DB 
  7. mysql_query('INSERT INTO Scores(name, score) VALUES(''.$name.'',''.$score.'')'); //insert new scores to DB 
  8. mysql_close(); 
  9. include('gethighscores.php'); //display highscores after insertion 
  10. ?> 


gethighscores.php
Syntax: [ Download ] [ Hide ]
  1. <? 
  2. mysql_connect(HOST, USER, PASS); 
  3. mysql_select_db(DB_NAME); //connect to mylsq server and select appropriate DB 
  4. $res = mysql_query('SELECT * FROM Scores ORDER BY score DESC LIMIT 100'); //select 100 highest scores 
  5. while($row = mysql_fetch_assoc($res) ) { 
  6. echo $row['name'].', '.$row['score']."n"; //output data as CSV 
  7. ?> 


Those 2 a really rough examples (they are good to learn how you should NOT write in PHP :) ) and they may contain errors in then (haven't checked them really :)) but hopefully they are enough to get you started.
mortefer
Experienced Developer
Experienced Developer
 
Posts: 54
Joined: Sat Dec 20, 2008 11:24 am

Postby snctln » Fri Jan 23, 2009 4:32 pm

thank you very much for the response and the rough example, that is exactly what I was looking for. I should be able to take your examples and through the power of google slap something together this weekend..

Thanks again I appreciate it
snctln
Freshman
Freshman
 
Posts: 5
Joined: Mon Jan 19, 2009 1:16 am

Scoring System

Postby talliez » Mon Apr 20, 2009 8:25 pm

Just a quick note to let you know that we are building a system for devs who don't know how, or don't want to build their own scoring systems. We're going to launch our beta on Friday, April 24th. The beta is pretty limited, so if you'd like to be considered visit Talliez
talliez
Once Poster
Once Poster
 
Posts: 1
Joined: Mon Apr 20, 2009 7:19 pm

Re: Desktop dev needs web dev advice

Postby alves89 » Mon Sep 10, 2012 4:06 am

Thanks for sharing, this is what I need to learn.
alves89
Junior Developer
Junior Developer
 
Posts: 15
Joined: Mon Sep 10, 2012 4:00 am

Top

Return to OFF-Topic

Who is online

Users browsing this forum: No registered users and 2 guests