My first "complete" prototype - Crokinole!

I’ve been tinkering around with physics and things bouncing off of other things, and discovered the game crokinole so I thought it would be a perfect fit for Codea and what I’d been doing with Codea anyway.

This prototype is more less “done”, though it does have its problems and would not be considered “done” if we were calling it anything but a prototype. Known issues are at the bottom of this post.

To play you’ll need to either replace the caroms and one of the game board sprites with basic ellipses of the proper dimensions, or go ahead and download the carom and board at these links:

Rules can be found here.

And here is a video of me giving the nickel tour.

And I’m putting the code at this link because my post is apparently 12,389 characters too long!

Sorry if there’s some way to embed links and video that I’m not aware of, and for the wall of text.

Thanks for reading and playing, if indeed you have, and enjoy!

Addendum - known issues (probably not an exhaustive list):

  • scoring: something is off but it’s not consistent. Shorter games (you can adjust how many caroms each player gets in the gameInit() function) seem to always score perfectly, full games (12 caroms each) frequently score incorrectly for at least one player. Haven’t tracked that down yet. Also scoring at the end is not displayed per the rules, it should be the player who scores the most actually gains in points the different between the two scores, but that’s such a trivial change I haven’t bothered to code that. I just display the two scores (otherwise I never would have known there was a scoring problem anyway).
  • restarting a game: touching the “game over” screen is supposed to restart the game, and it does… mostly. It seems that physics bodies from the prior game remain, which I can’t figure out because I’m marking them as “dead” and calling the same culling function at the end of the game to remove “dead” bodies.
  • it’s a rat’s nest: you’ll notice an almost allergic absence of “returns”. Every class and function is painfully “aware” of the existence of others. It’s a problem I can fix now that I’m a bit more proficient and have an understanding of why it’s not the best way to do things. It’s probably also contributing to my inability to find the first two bugs on this list. I’m not the most efficient coder yet, so for the most part I just did what worked and moved on to tackle other problems. I’m sure you’ll see something and go “why the hell did he do THAT?”
  • I also have no doubt there is tons of vestigial stuff in there from different dead ends and rabbit holes I went down in creating the game. I also copy and pasted some of this from my other projects and probably didn’t clean it all up. It’s a prototype!
  • graphics - it’s a prototype so it gets the job done, eh?
  • Rules: The broad strokes of the game are correct, but I’m sure I’ve missed some of the more subtle details in the rules. I’ve never actually played the board game so if any rule is missing it’s purely because I don’t know about it or didn’t read the rules carefully enough, not because the logic in the code is wrong. That said, I do sometimes see the game do something a LITTLE bit wrong, but it’s rare and happens sometimes so fast that I can’t decide if it was incorrect logic or if I just blinked and missed the action on the screen.

I also apologize for the investment in time this seems to require. The rules are actually not that long or difficult to grasp, but I know it’s annoying to have to visit twelve different links just to try something out.

Wow thats really good! very impressive indeed!

The collision detection looks spot on but I read that Codea has no built in collision detection. you did great! :slight_smile:

Thanks SteveNoob, but I can’t take the credit. That’s all Codea, it’s actually baked right in!

Whoops! You might need to know how to actually play the game if you don’t want to watch the video: Drag finger left and right to place carom. Double-tap to lock in position, then drag and release to shoot.

I watched the video, it looks really good!

I’m going to play it now :slight_smile:

@SteveNoob - Codea does have collision detection via physics objects

@SteveNoob also with circles you can use pos:dist(pos) < radius as a collision detector for circles, but otherwise the better collision detection is in the physics engine which handles polygons,chains,edges and circles.

BTW @Ignatz, thank you so much for your many excellent tutorials! I haven’t even nearly completed most of them, but they were insanely helpful in getting to a place where I feel like I can think up an idea and then know how I want to approach making it work in Codea. I still have tons to learn but feel like I have a great foundation thanks to your tutorials.