Results 1 to 6 of 6

Thread: Simple Snake Game - Castle Game Engine

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Shouldn't you be using maxy
    Fixed, thanks!
    I recommend you rename your unit1.pas
    Yes, I've fixed this also. Thank you!
    this procedure would take quite some time
    yes, that's possible, but I'm afraid optimizations will obfuscate the code. Still it'll have to test only 16*16*sqrt(2) combinations in average to find the last remaining tile to place a rabbit, i.e. 360 tests, which is affordable. The other problem is that it will hang up the next moment when there are no free tiles left
    Yes, I couldn't resist adding sprites for the snake, but actually I've tried to keep the code as simple and clear as it is possible and separate out any game-specific algorithms.
    Fixed possible freezing. Thanks!
    My free and opensource games: http://decoherence.itch.io/
    Sources are here: https://github.com/eugeneloza?tab=repositories

  2. #2
    Quote Originally Posted by eugeneloza View Post
    yes, that's possible, but I'm afraid optimizations will obfuscate the code.
    I'm aware of that. That is why I suggested using combination of current and optimized approach based on certain condition. This would allow people to know that optimization is optional.
    But regardless you should notify people that would potentially use your code about possible caveats that such code represents.

    Quote Originally Posted by eugeneloza View Post
    Still it'll have to test only 16*16*sqrt(2) combinations in average to find the last remaining tile to place a rabbit, i.e. 360 tests, which is affordable.
    I'm afraid your math won't hold. Why? Because it is quite possible that your random algorithm would generate same pair of X and Y coordinates multiple times. Now why is that? When generating random numbers most random number algorithms internally generate random floating value between 0 and 1 and then this number is linearly translated to integer value where internal value of 1 would be translated to maximum integer value you specified. This results in rounding the internal number at some time which means that several near floating numbers would translate to same output integer value and thus also the possibility for generating same pair of output values.

    Quote Originally Posted by eugeneloza View Post
    The other problem is that it will hang up the next moment when there are no free tiles left
    Easy solution.
    If your snake size equals to the number of all tiles on the map "Congratulations you won the game"

  3. #3
    Downloading. Thank-you!

    p.s: If it runs on Android...
    Last edited by Ñuño Martínez; 11-11-2016 at 10:58 AM.
    No signature provided yet.

  4. #4
    p.s: If it runs on Android...
    I've thought of porting it to Android. That's easy in Castle Game Engine. But I haven't done it yet.
    My free and opensource games: http://decoherence.itch.io/
    Sources are here: https://github.com/eugeneloza?tab=repositories

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •