Jump to content

slots

Featured Replies

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>

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.

Archived

This topic is now archived and is closed to further replies.

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.