This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Zaflis's profile picture

Minesweeper Game

Started by Zaflis, 12 January 2014 - 06:14 PM
Zaflis #1
Posted 12 January 2014 - 07:14 PM
Thought to post also my simple Minesweeper game (would've made own topic but it's not allowed yet).

Features:
- Play on big screen with your friends.
- Only supports advanced monitors, for touchscreen interface. Cannot play from terminal.
- Font and background coloring.
- Difficulty changeable via parameter from 0..1 (where 1 is field full of mines)
- Supports any amount of monitors. Characters are not scaled bigger by default, you need to change textscale value in code to do that. Also program restart required if you change monitors.

Missing:
- Cannot place flags, since i don't think the screen can recognize which mouse button you press in touchscreen event.

Pastebin: http://pastebin.com/WJuZjJzr

Spoiler
Lyqyd #2
Posted 12 January 2014 - 11:17 PM
I've split this into a new post. Don't just go around posting on random topics because you don't have topic creation permissions.
TheOddByte #3
Posted 13 January 2014 - 11:57 AM
The missing part there.. If this can be runned in the terminal then you can check if it's the right or left button that have been clicked.

local evt = { os.pullEvent() }
if evt[1] == "mouse_click" then
    if evt[2] == 1 then -- Left mouse button
        -- Code

    elseif evt[2] == 2 then -- Right mouse button
        -- Code

    elseif evt[2] == 3 then -- Middle mouse button
        -- Code
    end
end
NOTE: This doesn't work on monitors, Since you can only right click
Bomb Bloke #4
Posted 13 January 2014 - 04:42 PM
For monitors, you could either implement a button off to the side that toggles what the clicks do, or set up a system whereby a click places a flag and a double click reveals numbers.
Zaflis #5
Posted 14 January 2014 - 10:39 PM
For monitors, you could either implement a button off to the side that toggles what the clicks do, or set up a system whereby a click places a flag and a double click reveals numbers.
I thought about making a button that toggles flag mode, but i would imagine it being a little awkward when more people are playing it at the same time. I imagine that this game would work in very big scale, like 30x20 monitors that could be played in bat morph form or other methods of steady flying. One wants to dig and other wants to place flag, and it makes a problem. He could remove the flag toggle just as you are placing one.. and *boom*.

Doubleclick is maybe possible, but timing in server play is not that great either. It would require a time table for the entire grid (or dynamic list of recent clicks), and would create a delay for digging.

But feel free to edit and publish new versions of the game, i felt that it is enough for my needs for now at least.
Oose #6
Posted 20 January 2014 - 06:13 AM
This is cool. Nice to see games running on monitors. It makes the experience more like an actual display when playing with friends in SMP.
Agoldfish #7
Posted 20 January 2014 - 02:19 PM
Me and my friend take turns hitting the screen, first one to set off a mine loses. :D/>
TechedZombie #8
Posted 17 February 2015 - 11:15 PM
Cool. For the flags I know the event only can return the left click if on the computer screen but what if you use the monitor program ex "monitor right progName" will that work? and can it deteect left clicks in survival if it cant then that could be a cool new feature and im sure the developers can think of a way to make it work in creative like maybe monitors can only be broke from a "non-screen' side. But hey waht do I know?