fiveworlds Posted July 2, 2015 Posted July 2, 2015 So I made a simple slot machine game. But I was wondering normally when you press spin you get the moving wheel what would be the best approach for that? I was thinking maybe a random gif. <?php $num1 = rand(1, 5);$num2 = rand(1, 5);$num3 = rand(1, 5); $num4 = rand(1, 5);$num5 = rand(1, 5);$num6 = rand(1, 5); $num7 = rand(1, 5);$num8 = rand(1, 5);$num9 = rand(1, 5); $result1 = $num1.' | '.$num2.' | '.$num3; $result2 = $num4.' | '.$num5.' | '.$num6; $result3 = $num7.' | '.$num8.' | '.$num9; // Read points from file $filename = 'points.txt'; $handle = fopen($filename, 'r'); $current = fread($handle, filesize($filename)); fclose($handle); if ( ($num1 == $num2 && $num2 == $num3)||($num1 == $num5 && $num5 == $num9)|| ($num4 == $num5 && $num5 == $num6)||($num3 == $num5 && $num5 == $num7)|| ($num7 == $num8 && $num8 == $num9) ) { $status = '<big>You are a winner!</big>'; $add_points = $current + 10; // Add points to file $handle = fopen($filename, 'w'); $current_points = fwrite($handle, $add_points); fclose($handle); } else { $status = 'please try again!'; $handle = fopen($filename, 'w'); $add_points = $current - 2; $current_points = fwrite($handle, $add_points); fclose($handle); } ?> <html> <head> <title>Slot Machine Game!</title> </head> <body> <center><big><?php echo $result1; ?></big></center> <center><big><?php echo $result2; ?></big></center> <center><big><?php echo $result3; ?></big></center> <center><big><?php echo $status; ?></big></center> <center><big><?php echo 'You have <strong>'.$current.'</strong> points!'; ?></big></center> <center><a href='index.php'>spin</a></big></center> </body> </html>
Sensei Posted July 2, 2015 Posted July 2, 2015 CSS allows positioning element in x and y coords. Element can be found by JavaScript by ID, and its coordinate set. If you will set decreasing values, and repeat it (JavaScript timer), there will be animation. You should also control clipping of elements (one element inside of group of elements) to hide numbers.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now