-
Posts
166 -
Joined
-
Last visited
-
Days Won
1
Content Type
Profiles
Forums
Events
Everything posted by wrux
-
On my macbook air which I don't do much development on, only when i'm out the house. [ATTACH=CONFIG]1425[/ATTACH] My desktop I use one monitor for fullscreen apps and the other for file browsers and terminal etc but on my laptop I just use them all on fullscreen apps because the trackpad is so good to use
-
You could try using a batch find a replace tool to edit the .php out in every file
-
You'd do stuff like "rake new app_name" in the terminal to generate code files and then you can edit. It's fast to develop once you have a basic understanding (i've not used it much)
-
Why not use it as a redirect url?
-
Well most of it is automated so it's fast
-
eBlog, then you can blog about the other 3 ;) - - - Updated - - - If you use something like Ruby on Rails, you'd have one up and running in 2 hours tops (including learning the basics)
-
The second one.. ps is there supposed to be a poll? (I can't see anything)
-
[MENTION=70359]Markku[/MENTION] You could try using the item type ID instead of the name, might be easier $array = array( 4 => 'Eat', 6 => 'Drink ); You could use the item type id and reference it that way
-
Yea this big screen trend won't last. They are getting so big the buttons are all on the side so you can kind of use it one handed
-
What about using a switch case? $use_string = ''; switch($type) { case 'food': $use_string = 'Eat'; break; case 'drink': $use_string = 'Drink'; break; default: $$use_string = 'Use'; break; } echo $use_string; You probably don't need to complicate it that much but yea, or you could use an array like this... $item_uses = array( 'food' => 'Eat', 'drink' => 'Drink'); $use_string = in_array($i['itemtype'], $item_uses) ? $item_uses[$i['itemtype'] : 'Use';
-
I like android but the manufacturers faff about with the custom UI's too much. I've got an iPhone as most android phones are way to big nowadays & Apple have always been great with build quality and UI design
-
haaha, yea it does look a bit dodgy
-
User tagging & Interactions enhancements
wrux replied to ColdBlooded's topic in News and Announcements
[MENTION=70342]wrux[/MENTION] [MENTION=50433]ColdBlooded[/MENTION] Edit: Was testing if I could mention myself. -
Ahh ok, I just checked and it looks okay on desktop :cool:
-
Looks nice. You did a good job considering you said you said you haven't been programming long :)
-
Just realised theres an error in the code I posted. I think I must have clicked somewhere when I was posting this... This line: $end_date = new DateInterval(sprintf('P ', $investment_duration)); Needs to be replaced with this: $end_date = new DateInterval(sprintf('P%uD', $investment_duration)); And that should now create a timedelta of the number of days. Whoops :/
-
Ha cheers dude. I've noticed the massive difference with people's code on here, like how you changed the curly brackets. That's one reason I think i'll stick to python, no arguments over code indentation and brackets lol.
-
I have just updated my local code so that the database calls now use the procedural mysqli class. The only issue is that this requires an additional DB connection as not all of the website uses this. I'll post it anyway: In your globals you'd need to setup a MySQLi object called $mysqli first. <?php include "globals.php"; // // BANKING SETTINGS // // percesntage increase $investment_rate = 0.3; // duration in dats $investment_duration = 7; // select any investments in the bank $investment_query = sprintf('SELECT * FROM `investment_bank` WHERE `user_id` = \'%u\';', $userid); $investment = $mysqli->query($investment_query); $has_investment = $investment->num_rows; /* * Handle withdrawing funds */ if(isset($_GET['withdraw'])) { if($has_investment) { $i = $investment->fetch_assoc(); $now = new DateTime(); $d = date_create($i['finished']); if($d < $now) { // user has funds ready to withdraw $delete_sql = sprintf( "DELETE from `investment_bank` WHERE `user_id` = %u;", $userid ); if($mysqli->query($delete_sql)) { // deleted the reccord, now add the funds back to the user $update_user_sql = sprintf( 'UPDATE `users` SET `money` = `money` + %u WHERE `userid` = %u', $i['money'], $userid ); if($mysqli->query($update_user_sql)) { $messages->success('You have taken you money out the bank, you may now re-invest it!'); } else { $messages->error('There was an error, please contact an admin'); } } else { $messages->error('There was an error, please contact an admin'); } } else { $messages->error('You cannot access your funds yet'); } } else { $messages->error('You don\'t have any funds invested'); } header('Location: investmentbank.php'); } /* * Handle the Form POST */ if(isset($_POST['investment'])) { if($has_investment) { $messages->error('You already have an investment and cannot add another!'); } else { // form has been submitted $investment_ammount = (int) $_POST['investment']; if($investment_ammount > $ir['money']) { // player tried to invest more than they have $messages->error('You cannot invest more money than you have'); } else { // create some dates $date = new DateTime('now'); $end_date = new DateInterval(sprintf('P%uD', $investment_duration)); // calculated the correct end date $date->add($end_date); // construct the insert query $new_investment_sql = sprintf( "INSERT INTO `investment_bank` VALUES (NULL, %u, %u, '%s');", $userid, $investment_ammount + ($investment_ammount * $investment_rate), $date->format('Y-m-d H:i:s') ); if($result = $mysqli->query($new_investment_sql)) { // log message // deduct the user's money $mysqli->query(sprintf("UPDATE `users` SET `money` = %u WHERE `userid` = %u", $investment_ammount, $userid)); $messages->success('You invested $'. number_format($investment_ammount) .' in the investment bank and it will be available to collect in '. $investment_duration .' weeks'); } else { $messages->error('You encountered an error, please try again'); } } } // send player to the blank investment page header('Location: investmentbank.php'); } ?> <h2>Investment Banking</h2> <?php if($has_investment): ?> <?php $i = $investment->fetch_assoc();; $now = new DateTime(); $d = date_create($i['finished']); ?> <?php if($now > $d): ?> <p>You have $<?php echo number_format($i['money']); ?> and your investment has finished.</p> <p><a class="button" href="?withdraw">> withdraw funds</a></p> <?php else: ?> <p>You have $<?php echo number_format($i['money']); ?> invested until <?php echo date_format($d, 'Y-m-d'); ?>, come back then and you can withdraw the funds.</p> <?php endif; ?> <?php else: ?> <p>You do not have an investment yet.</p> <p>You can deposit money for <?php echo $investment_duration; ?> weeks and gain <?php echo $investment_rate*100; ?>% extra</p> <hr /> <p>How much do you wish to invest?</p> <form action="" method="POST"> <input id="investment-ammount" type="number" name="investment" placeholder="$100,000" min="0" max="<?php echo $ir['money']; ?>" step="100" /> <button>Invest</button> </form> <?php endif; ?> <style type="text/css"> #investment-ammount { width: 10em; } .messages { list-style: none; } .messages li { background: #f5f5f5; border: 1px solid #ccc; margin: 1em 3em 1em 0; padding: 1em; } .messages .message-error { color: #900; } .messages .message-success { color: #090; } </style> <?php $h->endpage(); ?>
-
Ahh, the alternative syntax is just more human readable so good for the template section
-
Yea I looked at the DB API but it sucked so I just used the mysql commands directly which is kinda bad but I guess I could update it
-
I've had a go at creating an app for mccodes and it's just a simple investment bank but I guess it's a start. I know it's not very imaginative, but I guess it's better than nothing. First off, i'm not sure what kind of APIs people have created, but I wrote a super simple flash message class just incase people don't have one already. [ATTACH=CONFIG]1398[/ATTACH][ATTACH=CONFIG]1399[/ATTACH][ATTACH=CONFIG]1400[/ATTACH][ATTACH=CONFIG]1401[/ATTACH] Ok so first of all, this requires at least PHP 5.3 and it requires you to change the DB engine for the users table, nothing to bad, it may cause some problems if you don't do this. So heres the SQL to run: ALTER TABLE `users` ADD INDEX (`userid`); ALTER TABLE `users` ENGINE = INNODB; CREATE TABLE `investment_bank` ( `id` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(11) NOT NULL, `money` int(11) unsigned NOT NULL, `finished` datetime NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `user_to` (`user_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; ALTER TABLE `investment_bank` ADD CONSTRAINT `investment_bank_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `users` (`userid`); If you wish to use the flash message class then add this somewhere in global_func.php. It's nothing complex (DRY and all that jazz though?) and i'm sure the use of __toString() is incorrect, but it's just a shortcut. /* Messages Class Handles the flash messages. Maybe add support for other methods like DB emssages? or COOKIE messages? */ class Messages { public function error($msg) { $_SESSION['FLASH'][] = array('type'=>'error', 'text'=>$msg); } public function success($msg) { $_SESSION['FLASH'][] = array('type'=>'success', 'text'=>$msg); } public function warning($msg) { $_SESSION['FLASH'][] = array('type'=>'warning', 'text'=>$msg); } public function get() { return $_SESSION['FLASH']; } public function remove() { unset($_SESSION['FLASH']); } public function __toString() { return count($_SESSION['FLASH']) ? true : false; } } Then if you open up globals.php; right AFTER require "global_func.php"; add this line: $messages = new Messages; Somewhere in your template, you'd now want to display the messages so add this section: // Display the flash messages if($messages) { echo '<ul class="messages">'; foreach($messages->get() as $message) { echo '<li class="message-'.$message['type'].'">'.$message['text'].'</li>'; } $messages->remove(); echo '</ul>'; } And finally, heres the investmentbank.php code you need to add: <?php include "globals.php"; // // BANKING SETTINGS // // percesntage increase $investment_rate = 0.3; // duration in dats $investment_duration = 7; // select any investments in the bank $investment_query = sprintf('SELECT * FROM `investment_bank` WHERE `user_id` = \'%u\';', $userid); $investment = $db->query($investment_query); $has_investment = mysql_num_rows($investment); /* * Handle withdrawing funds */ if(isset($_GET['withdraw'])) { if($has_investment) { $i = mysql_fetch_assoc($investment); $now = new DateTime(); $d = date_create($i['finished']); if($d < $now) { // user has funds ready to withdraw $delete_sql = sprintf( "DELETE from `investment_bank` WHERE `user_id` = %u;", $userid ); if(mysql_query($delete_sql)) { // deleted the reccord, now add the funds back to the user $update_user_sql = sprintf( 'UPDATE `users` SET `money` = `money` + %u WHERE `userid` = %u', $i['money'], $userid ); if(mysql_query($update_user_sql)) { $messages->success('You have taken you money out the bank, you may now re-invest it!'); } else { $messages->error('There was an error, please contact an admin'); } } else { $messages->error('There was an error, please contact an admin'); } } else { $messages->error('You cannot access your funds yet'); } } else { $messages->error('You don\'t have any funds invested'); } header('Location: investmentbank.php'); } /* * Handle the Form POST */ if(isset($_POST['investment'])) { if($has_investment) { $messages->error('You already have an investment and cannot add another!'); //echo 'x'; } else { // form has been submitted $investment_ammount = (int) $_POST['investment']; if($investment_ammount > $ir['money']) { // player tried to invest more than they have $messages->error('You cannot invest more money than you have'); } else { echo 'try and save <br />'; // create some dates $date = new DateTime('now'); $end_date = new DateInterval(sprintf('P ', $investment_duration)); // calculated the correct end date $date->add($end_date); // construct the insert query $new_investment_sql = sprintf( "INSERT INTO `investment_bank` VALUES (NULL, %u, %u, '%s');", $userid, $investment_ammount + ($investment_ammount * $investment_rate), $date->format('Y-m-d H:i:s') ); if($result = mysql_query($new_investment_sql)) { // log message // deduct the user's money mysql_query(sprintf("UPDATE `users` SET `money` = %u WHERE `userid` = %u", $investment_ammount, $userid)); $messages->success('You invested $'. number_format($investment_ammount) .' in the investment bank and it will be available to collect in '. $investment_duration .' weeks'); } else { $messages->error('You encountered an error, please try again'); } } } // send player to the blank investment page header('Location: investmentbank.php'); } ?> <h2>Investment Banking</h2> <?php if($has_investment): ?> <?php $i = mysql_fetch_assoc($investment); $now = new DateTime(); $d = date_create($i['finished']); ?> <?php if($now > $d): ?> <p>You have $<?php echo number_format($i['money']); ?> and your investment has finished.</p> <p><a class="button" href="?withdraw">> withdraw funds</a></p> <?php else: ?> <p>You have $<?php echo number_format($i['money']); ?> invested until <?php echo date_format($d, 'Y-m-d'); ?>, come back then and you can withdraw the funds.</p> <?php endif; ?> <?php else: ?> <p>You do not have an investment yet.</p> <p>You can deposit money for <?php echo $investment_duration; ?> weeks and gain <?php echo $investment_rate*100; ?>% extra</p> <hr /> <p>How much do you wish to invest?</p> <form action="" method="POST"> <input id="investment-ammount" type="number" name="investment" placeholder="$100,000" min="0" max="<?php echo $ir['money']; ?>" step="100" /> <button>Invest</button> </form> <?php endif; ?> <style type="text/css"> #investment-ammount { width: 10em; } .messages { list-style: none; } .messages li { background: #f5f5f5; border: 1px solid #ccc; margin: 1em 3em 1em 0; padding: 1em; } .messages .message-error { color: #900; } .messages .message-success { color: #090; } </style> <?php $h->endpage(); ?> One thing to note is the lack of ORM and if somebody has written a decent ORM for mccodes then i'd be happy to update my code, but for now I just used super old code which works, but it's not ideal.
-
So i've created an interesting flat design & whilst it's not perfect (i'll make changes to this) it's something a bit different. Any thoughts? [ATTACH=CONFIG]1395[/ATTACH] [ATTACH=CONFIG]1396[/ATTACH] [ATTACH=CONFIG]1397[/ATTACH] The two smaller screenshots show hovering over certain elements; the game name has an animation and the vitals just display/hide.
-
I've taken a bit out but this is what i've currently got (made this with LaTex quick) Multiple gyms would give progressively greater multipliers (base being 1) The stat value is incorporated Type multiplier is for if certain stats are slower/faster to train. (you could also add stuff effects here that might buff the user's training)
-
Introducing Criminal Force, the first cops and robbers game
wrux replied to Cfikem's topic in Game Projects
Looks very well done :) -
It's typically better to design from mobile up. Scaling a desktop website down may cause too many issues. If you start by building the mobile version and scaling it up, you'd run into less problems. Using front end frameworks are always helpful