Code Monkey home page Code Monkey logo

tictactoe's Introduction

tictactoe

A mobile game built in Flutter. You can find it published on stores:

This game was built using the game_template that you'll find in github.com/flutter/samples.

Note: The name of the game in app stores is "Tic Tac Toe Puzzle Game". Because that's what it is, and because every other variation of "Tic Tac Toe" is already taken.

Demo

To make it easier for everyone to play with the sample, it's currently published as a web demo, too, in two versions:

Development

To run the app in debug mode:

flutter run

Code organization

Code is organized in a loose and shallow feature-first fashion. In lib/src, you'll therefore find directories such as ads, ai, audio or main_menu. Nothing fancy, but usable.

The state management approach is intentionally low-level. That way, it's easy to take this project and run with it, without having to learn new paradigms, or having to remember to run flutter pub run build_runner watch. You are, of course, encouraged to use whatever paradigm, helper package or code generation scheme to build on top of this project.

Building for production

The following assumes using FVM. Just remove fvm from the commands if you don't use FVM for Flutter version management.

To build and publish to github.io:

fvm flutter pub global run peanut \
--web-renderer canvaskit \
--extra-args "--base-href=/tictactoe/" \
&& git push origin --set-upstream gh-pages

To build the app for iOS (and open Xcode when finished):

fvm flutter build ipa --bundle-sksl-path warmup_2022-05-12_ios.sksl.json && open build/ios/archive/Runner.xcarchive

To build the app for Android (and open the folder with the bundle when finished):

fvm flutter build appbundle --bundle-sksl-path warmup_2024-01-30_android_pixel5.sksl.json && open build/app/outputs/bundle/release

SkSL shaders

To update the warmup_2022-04-27_xxx.sksl.json files used in the commands above, use the official SkSL shader warmup guide.

The game, despite being simple, uses shaders all over the place for the "drawing ink" effect. In my testing, the performance is fine on most reasonable devices, but why not make it even better?

Note: You can remove the --bundle-sksl-path warmup_xxx.json part of the commands above if you're in a place where you care more about development speed than performance. For example, when you need a quick turnaround for some testing and can't be bothered to manually re-capture the shaders.

Icon

Updating the launcher icon:

fvm flutter pub run flutter_launcher_icons

tictactoe's People

Contributors

ashishawasthi avatar domesticmouse avatar filiph avatar newtadev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tictactoe's Issues

"Exception: Error running pod install" on first try

14:06:30 tictactoe$ flutter --version
Flutter 3.10.6 • channel stable • https://github.com/flutter/flutter.git
Framework • revision f468f3366c (2 weeks ago) • 2023-07-12 15:19:05 -0700
Engine • revision cdbeda788a
Tools • Dart 3.0.6 • DevTools 2.23.1

Running on a MacBook M1 Pro, macOS Ventura 13.4.1, ran the following commands which failed with the error shown in the subject line. I tried running the recommended command ("pod repo update") but it didn't seem to help.

14:08:09 tictactoe$ flutter clean
Cleaning Xcode workspace...                                      1,818ms
Cleaning Xcode workspace...                                      2,186ms
Deleting build...                                                   11ms
Deleting .dart_tool...                                               1ms
Deleting Generated.xcconfig...                                       0ms
Deleting flutter_export_environment.sh...                            0ms
Deleting ephemeral...                                                3ms
Deleting .flutter-plugins-dependencies...                            0ms
Deleting .flutter-plugins...                                         0ms
14:08:19 tictactoe$ flutter run
Connected devices:
macOS (desktop) • macos  • darwin-arm64   • macOS 13.4.1 22F770820d darwin-arm64
Chrome (web)    • chrome • web-javascript • Google Chrome 115.0.5790.114

Checking for wireless devices...

[1]: macOS (macos)
[2]: Chrome (chrome)
Please choose one (or "q" to quit): 1
Resolving dependencies... (1.6s)
  _fe_analyzer_shared 39.0.0 (62.0.0 available)
+ _flutterfire_internals 1.3.4
  analyzer 4.0.0 (6.0.0 available)
  archive 3.3.0 (3.3.7 available)
  args 2.3.1 (2.4.2 available)
> async 2.11.0 (was 2.8.2)
> audioplayers 1.2.0 (was 0.20.1) (5.0.0 available)
+ audioplayers_android 1.1.3 (4.0.0 available)
+ audioplayers_darwin 1.0.4 (5.0.0 available)
+ audioplayers_linux 1.0.2 (3.0.0 available)
+ audioplayers_platform_interface 2.1.0 (6.0.0 available)
+ audioplayers_web 2.1.0 (4.0.0 available)
+ audioplayers_windows 1.1.1 (3.0.0 available)
> boolean_selector 2.1.1 (was 2.1.0)
> characters 1.3.0 (was 1.2.0)
+ checked_yaml 2.0.3
+ cli_util 0.3.5 (0.4.0 available)
> clock 1.1.1 (was 1.1.0)
> collection 1.17.1 (was 1.16.0) (1.18.0 available)
  convert 3.0.1 (3.1.1 available)
  coverage 1.3.0 (1.6.3 available)
  crypto 3.0.2 (3.0.3 available)
  cupertino_icons 1.0.4 (1.0.5 available)
> fake_async 1.3.1 (was 1.3.0)
  ffi 1.1.2 (2.0.2 available)
  file 6.1.2 (7.0.0 available)
> firebase_core 2.15.0 (was 1.16.0)
> firebase_core_platform_interface 4.8.0 (was 4.3.0)
> firebase_core_web 2.6.0 (was 1.6.3)
> firebase_crashlytics 3.3.4 (was 2.7.2)
> firebase_crashlytics_platform_interface 3.6.4 (was 3.2.5)
> flutter_launcher_icons 0.10.0 (was 0.9.2) (0.13.1 available)
  flutter_lints 2.0.1 (2.0.2 available)
> frontend_server_client 3.2.0 (was 2.1.2)
> games_services 3.0.1 (was 2.0.8)
> games_services_platform_interface 3.0.1 (was 2.0.6)
  glob 2.0.2 (2.1.2 available)
> go_router 5.2.4 (was 3.1.0) (10.0.0 available)
> google_mobile_ads 2.4.0 (was 1.2.0) (3.0.0 available)
  http 0.13.4 (1.1.0 available)
  http_multi_server 3.2.0 (3.2.1 available)
  http_parser 4.0.0 (4.0.2 available)
  image 3.1.3 (4.0.17 available)
  in_app_purchase 3.0.4 (3.1.7 available)
  in_app_purchase_android 0.2.2+5 (0.3.0+10 available)
  in_app_purchase_platform_interface 1.3.1 (1.3.4 available)
  in_app_purchase_storekit 0.3.0+7 (0.3.6+4 available)
  io 1.0.3 (1.0.4 available)
> js 0.6.7 (was 0.6.4)
  json_annotation 4.5.0 (4.8.1 available)
  lints 2.0.0 (2.1.1 available)
> logging 1.2.0 (was 1.0.2)
> matcher 0.12.15 (was 0.12.11) (0.12.16 available)
> material_color_utilities 0.2.0 (was 0.1.4) (0.8.0 available)
> meta 1.9.1 (was 1.7.0)
  mime 1.0.2 (1.0.4 available)
  node_preamble 2.0.1 (2.0.2 available)
  package_config 2.0.2 (2.1.0 available)
> path 1.8.3 (was 1.8.1)
> path_provider 2.0.15 (was 2.0.10)
  path_provider_android 2.0.14 (2.0.27 available)
+ path_provider_foundation 2.2.4
  path_provider_linux 2.1.6 (2.1.11 available)
  path_provider_platform_interface 2.0.4 (2.0.6 available)
  path_provider_windows 2.0.6 (2.1.7 available)
  petitparser 5.0.0 (5.4.0 available)
> plugin_platform_interface 2.1.5 (was 2.1.2)
  pool 1.5.0 (1.5.1 available)
  provider 6.0.2 (6.0.5 available)
  pub_semver 2.1.1 (2.1.4 available)
  shared_preferences 2.0.15 (2.2.0 available)
  shared_preferences_android 2.0.12 (2.2.0 available)
  shared_preferences_linux 2.1.1 (2.3.0 available)
  shared_preferences_macos 2.0.4 (2.0.5 available)
  shared_preferences_platform_interface 2.0.0 (2.3.0 available)
  shared_preferences_web 2.0.4 (2.2.0 available)
  shared_preferences_windows 2.1.1 (2.3.0 available)
  shelf 1.3.0 (1.4.1 available)
  shelf_packages_handler 3.0.0 (3.0.2 available)
  shelf_static 1.1.0 (1.1.2 available)
  shelf_web_socket 1.0.1 (1.0.4 available)
  source_map_stack_trace 2.1.0 (2.1.1 available)
  source_maps 0.10.10 (0.10.12 available)
> source_span 1.9.1 (was 1.8.2) (1.10.0 available)
> stack_trace 1.11.0 (was 1.10.0) (1.11.1 available)
> stream_channel 2.1.1 (was 2.1.0) (2.1.2 available)
> string_scanner 1.2.0 (was 1.1.0)
> term_glyph 1.2.1 (was 1.2.0)
> test 1.24.1 (was 1.21.1) (1.24.4 available)
> test_api 0.5.1 (was 0.4.9) (0.6.1 available)
> test_core 0.5.1 (was 0.4.13) (0.5.4 available)
  typed_data 1.3.0 (1.3.2 available)
  uuid 3.0.6 (3.0.7 available)
> vector_math 2.1.4 (was 2.1.2)
+ visibility_detector 0.3.3 (0.4.0+2 available)
  vm_service 8.3.0 (11.8.0 available)
  watcher 1.0.1 (1.1.0 available)
  web_socket_channel 2.2.0 (2.4.0 available)
  webkit_inspection_protocol 1.0.1 (1.2.0 available)
  win32 2.5.2 (5.0.6 available)
  xdg_directories 0.2.0+1 (1.0.1 available)
  xml 5.4.1 (6.3.0 available)
  yaml 3.1.0 (3.1.2 available)
These packages are no longer being depended on:
- path_provider_ios 2.0.9
- path_provider_macos 2.0.6
Changed 48 dependencies!
Launching lib/main.dart on macOS in debug mode...
Updating project for Xcode compatibility.
Upgrading project.pbxproj
Upgrading Runner.xcscheme
Removing script build phase dependency analysis.
Running pod install...                                             689ms
CocoaPods' output:
↳
      Preparing

    Analyzing dependencies

    Inspecting targets to integrate
      Using `ARCHS` setting to build architectures of target `Pods-Runner`: (``)

    Finding Podfile changes
      A audioplayers_darwin
      A path_provider_foundation
      R audioplayers
      R path_provider_macos
      - FlutterMacOS
      - firebase_core
      - firebase_crashlytics
      - games_services
      - shared_preferences_macos

    Fetching external sources
    -> Fetching podspec for `FlutterMacOS` from `Flutter/ephemeral`
    -> Fetching podspec for `audioplayers_darwin` from
    `Flutter/ephemeral/.symlinks/plugins/audioplayers_darwin/macos`
    -> Fetching podspec for `firebase_core` from
    `Flutter/ephemeral/.symlinks/plugins/firebase_core/macos`
    firebase_core: Using Firebase SDK version '10.12.0' defined in 'firebase_core'
    -> Fetching podspec for `firebase_crashlytics` from
    `Flutter/ephemeral/.symlinks/plugins/firebase_crashlytics/macos`
    firebase_crashlytics: Using Firebase SDK version '10.12.0' defined in 'firebase_core'
    -> Fetching podspec for `games_services` from
    `Flutter/ephemeral/.symlinks/plugins/games_services/macos`
    -> Fetching podspec for `path_provider_foundation` from
    `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`
    -> Fetching podspec for `shared_preferences_macos` from
    `Flutter/ephemeral/.symlinks/plugins/shared_preferences_macos/macos`

    Resolving dependencies of `Podfile`
      CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local because checking is
      only performed in repo update
      CDN: trunk Relative path: all_pods_versions_0_3_5.txt exists! Returning local because
      checking is only performed in repo update
      CDN: trunk Relative path: Specs/0/3/5/Firebase/10.12.0/Firebase.podspec.json exists!
      Returning local because checking is only performed in repo update
      CDN: trunk Relative path: all_pods_versions_c_0_4.txt exists! Returning local because
      checking is only performed in repo update
      CDN: trunk Relative path: Specs/c/0/4/Flutter/3.0.0/Flutter.podspec.json exists! Returning
      local because checking is only performed in repo update
      CDN: trunk Relative path: Specs/0/3/5/Firebase/10.12.0/Firebase.podspec.json exists!
      Returning local because checking is only performed in repo update
    [!] CocoaPods could not find compatible versions for pod "Firebase/CoreOnly":
      In snapshot (Podfile.lock):
        Firebase/CoreOnly (= 8.15.0, ~> 8.15.0)

      In Podfile:
        firebase_core (from `Flutter/ephemeral/.symlinks/plugins/firebase_core/macos`) was
        resolved to 2.15.0, which depends on
          Firebase/CoreOnly (~> 10.12.0)


    You have either:
     * out-of-date source repos which you can update with `pod repo update` or with `pod install
     --repo-update`.
     * changed the constraints of dependency `Firebase/CoreOnly` inside your development pod
     `firebase_core`.
       You should run `pod update Firebase/CoreOnly` to apply changes you've made.

    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/molinillo-0.8.0/lib/molinillo/resolution.r
    b:317:in `raise_error_unless_state'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/molinillo-0.8.0/lib/molinillo/resolution.r
    b:299:in `block in unwind_for_conflict'
    <internal:kernel>:90:in `tap'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/molinillo-0.8.0/lib/molinillo/resolution.r
    b:297:in `unwind_for_conflict'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/molinillo-0.8.0/lib/molinillo/resolution.r
    b:257:in `process_topmost_state'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/molinillo-0.8.0/lib/molinillo/resolution.r
    b:182:in `resolve'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/molinillo-0.8.0/lib/molinillo/resolver.rb:
    43:in `resolve'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/resolver.rb
    :94:in `resolve'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer/a
    nalyzer.rb:1082:in `block in resolve_dependencies'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/user_interf
    ace.rb:64:in `section'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer/a
    nalyzer.rb:1080:in `resolve_dependencies'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer/a
    nalyzer.rb:125:in `analyze'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer.r
    b:422:in `analyze'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer.r
    b:244:in `block in resolve_dependencies'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/user_interf
    ace.rb:64:in `section'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer.r
    b:243:in `resolve_dependencies'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/installer.r
    b:162:in `install!'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/command/ins
    tall.rb:52:in `run'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/claide-1.1.0/lib/claide/command.rb:334:in
    `run'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/lib/cocoapods/command.rb:
    52:in `run'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/gems/cocoapods-1.12.1/bin/pod:55:in `<top
    (required)>'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/bin/pod:25:in `load'
    /opt/homebrew/Cellar/cocoapods/1.12.1/libexec/bin/pod:25:in `<main>'

Error output from CocoaPods:
↳
    dyld[8153]: Library not loaded: /usr/local/opt/gmp/lib/libgmp.10.dylib
      Referenced from: <0DC93DF4-2A65-3D65-8140-6919F11592CC>
      /Users/marccohen/.rbenv/versions/3.2.1/bin/ruby
      Reason: tried: '/usr/local/opt/gmp/lib/libgmp.10.dylib' (no such file),
      '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/gmp/lib/libgmp.10.dylib' (no such
      file), '/usr/local/opt/gmp/lib/libgmp.10.dylib' (no such file),
      '/usr/local/lib/libgmp.10.dylib' (no such file), '/usr/lib/libgmp.10.dylib' (no such file,
      not in dyld cache)

Error: CocoaPods's specs repository is too out-of-date to satisfy dependencies.
To update the CocoaPods specs, run:
  pod repo update



Exception: Error running pod install
14:08:41 tictactoe$ 

multiplayer

will there eventually be multi player mode?

Zone mismatch error

Error log

The following assertion was thrown during runApp:
Zone mismatch.
The Flutter bindings were initialized in a different zone than is now being used. This will likely
cause confusion and bugs as any zone-specific configuration will inconsistently use the
configuration of the original binding initialization zone or this zone based on hard-to-predict
factors such as which zone was active when a particular callback was set.
It is important to use the same zone when calling ensureInitialized on the binding as when calling
runApp later.
To make this warning fatal, set BindingBase.debugZoneErrorsAreFatal to true before the bindings are
initialized (i.e. as the first statement in void main() { }).

Yes i already this Zone mismatch Migration guide but it don't work

Future<void> main() async {
  FirebaseCrashlytics? crashlytics;

  if (!kIsWeb && (Platform.isIOS || Platform.isAndroid)) {
    try {
      WidgetsFlutterBinding.ensureInitialized();
      await Firebase.initializeApp(
        options: DefaultFirebaseOptions.currentPlatform,
      );
      crashlytics = FirebaseCrashlytics.instance;
    } catch (e) {
      debugPrint("Firebase couldn't be initialized: $e");
    }
  }

  await guardWithCrashlytics(
    guardedMain,
    crashlytics: crashlytics,
  );
}
void guardedMain() async {
   /// other code
    runApp();
}

@filiph Do you have any thoughts about it?

Error: `@staticInterop` classes should not contain any generative constructors. Use factory constructors instead.

When building this app locally on latest flutter version. I ran into an issue with audio

../../../../AppData/Local/Pub/Cache/hosted/pub.dev/audioplayers_web-2.1.0/lib/web_audio_js.dart:8:12: Error: `@staticInterop` classes should
not contain any generative constructors.
Use factory constructors instead.
  external JsAudioContext();

I resolve it by modifying the code it's and implementing factory constructors.

import 'dart:html';
import 'package:js/js.dart';

@JS('AudioContext')
@staticInterop
class JsAudioContext {
  external factory JsAudioContext();
}

extension JsAudioContextExtension on JsAudioContext {
  external MediaElementAudioSourceNode createMediaElementSource(
    AudioElement element,
  );

  external StereoPannerNode createStereoPanner();

  external AudioNode get destination;
}

@JS()
@staticInterop
abstract class AudioNode {
  external factory AudioNode();
}

extension AudioNodeExtension on AudioNode {
  external AudioNode connect(AudioNode audioNode);
}

@JS()
@staticInterop
class AudioParam {
  external factory AudioParam();
}

extension AudioParamExtension on AudioParam {
  external num get value;
  external set value(num value);
}

@JS()
@staticInterop
class StereoPannerNode implements AudioNode {
  external factory StereoPannerNode();
}

extension StereoPannerNodeExtension on StereoPannerNode {
  external AudioParam get pan;
}

@JS()
@staticInterop
class MediaElementAudioSourceNode implements AudioNode {
  external factory MediaElementAudioSourceNode();
}

Although this resolved my issue, and I could hear the audio, I don't believe modifying a file in AppData should be the solution. Any idea on what the actual solution should be? I'm new to using Flutter.

in app purchase not working

SettingsScreen ->

When tap on

_SettingsLine(
'Remove ads',
icon,
onSelected: callback,
);

                a CircularProgressIndicator displays for 5s and then after that there is no response from the app store

Level info

Cool game. One suggestion. When playing each level I didn't know how many Xs I needed to get in a row in order to win. It would be nice to know that as soon as the level starts.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.