Snake Slider, my coolest game :)

Previous topic - Next topic

Slydog

#30
If you think it may help, here's my kinetic scrolling code from my GUI.
It calls/uses tons of my other library code, but you can use this as a framework to see how I handle the various touch states and scrolling 'physics'.  Keep in mind it is still a 'work in progress' as I'm not too happy on how it slows down, it's too abrupt, but it is tweakable, just haven't found the right 'tweak'.

Code (glbasic) Select
CONSTANT FLICK_STATE_OFF% = 0
CONSTANT FLICK_STATE_TOUCHING% = 1
CONSTANT FLICK_STATE_MOVING% = 2
CONSTANT FLICK_STATE_FLICKING% = 3

TYPE TXyXy
x1%
y1%
x2%
y2%

FUNCTION Set: x1%, y1%, x2%, y2%
self.x1 = x1
self.y1 = y1
self.x2 = x2
self.y2 = y2
ENDFUNCTION

FUNCTION Move: point AS TPoint
INC self.x1, point.x
INC self.x2, point.x
INC self.y1, point.y
INC self.y2, point.y
ENDFUNCTION
ENDTYPE

TYPE TFlick
time#
pos#
ENDTYPE
GLOBAL _flick[] AS TFlick

... in my 'TGui_Scroll' TYPE ....
TYPE TGui_Scroll
details AS TGui_Common
pos% = 0
pos_max% = 0
allow_events% = TRUE
state% = FLICK_STATE_OFF
speed# = -1
touch_start% = -1
y_start% = 0
direction% = 0
offset_start% = -1
is_infinite% = FALSE

FUNCTION IsScroll%: offset AS TPoint
IF NOT self.details.enabled THEN RETURN
LOCAL rv% = 0
LOCAL DISTANCE_FACTOR# = 300.0
LOCAL SPEED_FACTOR# = 35.0
LOCAL SPEED_MIN# = 5.0
LOCAL SPEED_MAX# = 40.0
LOCAL FRICTION# = 15.0
LOCAL MOVE_MIN% = 10
LOCAL y%
LOCAL b1%, b1_prev%
LOCAL is_click%
LOCAL flick AS TFlick
LOCAL flick_move#

LOCAL xy AS TXyXy
xy = self.details.xy   // Get the top left xy and bottom right xy of this scroll area
xy.Move(offset)

y = _mouse[0].y
b1 = _mouse[0].b1
b1_prev = _mouse[0].b1_prev  // Last frame's button state
is_click = Input_IsClick(xy) // Is user clicking inside this xy1,xy2 rectangle?

// Finger went off of the scroll area
//IF (MOVING = TRUE) AND (FLICKING = FALSE) AND (is_click = FALSE)
// Don't need this check for my purposes
//ENDIF

SELECT self.state

CASE FLICK_STATE_OFF
// Very first touch?
IF (b1 = TRUE) AND (b1_prev = FALSE) AND (is_click = TRUE)
self.state = FLICK_STATE_TOUCHING
self.allow_events = TRUE
self.touch_start = y
self.offset_start = self.pos
DIM _flick[0] // Clear previous flick array
flick.time = GETTIMERALL()
flick.pos = y
DIMPUSH _flick[], flick
ENDIF

CASE FLICK_STATE_TOUCHING
// Have we moved enough to start a flick move?
IF ABS(y - self.touch_start) > MOVE_MIN
self.state = FLICK_STATE_MOVING
self.allow_events = FALSE
rv = TRUE
ENDIF
// Took finger off before starting a flick move?
IF (b1 = FALSE) AND (self.state = FLICK_STATE_TOUCHING)
self.state = FLICK_STATE_OFF
self.allow_events = TRUE
// Click event should be passed to child gui control
ENDIF

CASE FLICK_STATE_MOVING
// Still Moving?  Log current flick point.
IF b1 = TRUE
flick.time = GETTIMERALL()
flick.pos = y
DIMPUSH _flick[], flick
IF BOUNDS(_flick[], 0) > 3 THEN DIMDEL _flick[], 0
self.pos = self.offset_start + (self.touch_start - y)
// JUST took finger off
ELSE
self.state = FLICK_STATE_FLICKING
self.allow_events = FALSE
IF LEN(_flick[]) > 1
self.speed = (_flick[-1].pos - _flick[0].pos) / (_flick[-1].time - _flick[0].time) * SPEED_FACTOR // speed = distance / time
ELSE
self.speed = 0
ENDIF
self.direction = SGN(self.speed) * -1
self.speed = ABS(self.speed)
ENDIF

CASE FLICK_STATE_FLICKING
// Cancel flick with a new touch?
IF (b1 = TRUE) AND (is_click = TRUE)
self.state = FLICK_STATE_TOUCHING
self.allow_events = TRUE
self.touch_start = y
self.offset_start = self.pos
DIM _flick[0]
flick.time = GETTIMERALL()
flick.pos = y
DIMPUSH _flick[], flick
// Flick finished?
ELSEIF self.speed < SPEED_MIN
self.state = FLICK_STATE_OFF
self.allow_events = TRUE
// Continue flick
ELSE
flick_move = MIN(SPEED_MAX, self.speed)
flick_move = flick_move * (GETTIMER() / 100.0)
INC self.pos, flick_move * self.direction
// We've reach the top
// IF self.pos < 0 THEN INC self.pos, self.pos_max
// IF self.pos > self.pos_max THEN DEC self.pos, self.pos_max
// We've reach the top or bottom?
IF NOT self.is_infinite
IF (self.pos <= 0) OR (self.pos >= self.pos_max)
self.state = FLICK_STATE_OFF
self.speed = 0
ENDIF
ENDIF

IF self.speed > 0 THEN DEC self.speed, FRICTION / GETTIMER()
ENDIF

ENDSELECT

IF self.is_infinite
IF self.pos < 0 THEN INC self.pos, self.pos_max
IF self.pos > self.pos_max THEN DEC self.pos, self.pos_max
ELSE
IF self.pos < 0 THEN self.pos = 0
IF self.pos > self.pos_max THEN self.pos = self.pos_max
ENDIF
self.details.was_mouse_down = b1
ENDFUNCTION
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

BdR

I've updated my Snake Slider game again and added a hints option (both the iOS and WebOS versions). Some users found some puzzles too difficult, so I've added hints similar to "Move the box" app. Users can get hints (3 in Lite version, 8 in Full version) by giving the app a rating. Players can then use the hints to see the solution of a puzzle.

Also, some puzzles were optimized and the credits now also shows the GLBasic logo. :good:

BdR

Snake Slider was updated just a few minutes ago (the iTC Mobile app notification are really handy). Anyway, still no kinetic scrolling but the update does add a red carpet which holds 25 brand new levels. This brings the total number of puzzles to 150!

Here's a picture of all the new levels. I've made sure to also include some easier puzzles, but the last two are tough as nails. :whip: :D



cheers,
Bas

Schranz0r

I like the game, have played the version for WebOS !
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Kitty Hello

The option with the tetris-stones is nice!
A good friend made a game on the Amiga, where you had to push such tetris-like stones into holes in the ground to walk over them. And it had bombs where you could explode/break apart these stones. It was pretty sophisticated.

Albert

I've found this game similar to yours (of course there are differencies even in the gamemechanic). I think you'll find it interesting.
http://onemorelevel.com/game/choo_choo_puzzle

Hark0

http://litiopixel.blogspot.com
litiopixel.blogspot.com - Desarrollo videojuegos Indie · Pixel-Art · Retroinformática · Electrónica Development Indie Videogames · Pixel-Art · Retrocomputing · Electronic

BdR

Quote from: Kitty Hello on 2012-Jul-04
The option with the tetris-stones is nice!
A good friend made a game on the Amiga, where you had to push such tetris-like stones into holes in the ground to walk over them. And it had bombs where you could explode/break apart these stones. It was pretty sophisticated.
You mean like in "Chips challenge" where you can push blockinto the in water but with tetris blocks? Was it ever published or release?

Quote from: Albert on 2012-Jul-04
I've found this game similar to yours (of course there are differencies even in the gamemechanic). I think you'll find it interesting.
http://onemorelevel.com/game/choo_choo_puzzle
Yeah, I played that one already, it's very cool. Basically it exactly the same except it's on a hexagon grid instead of squares (and without grow/shrink items)

Kitty Hello

No release. Not even any trace of the game anymore. Yes, lik Chips Challenge, but the Blocks were a lot bigger and irregularly shaped, plus you could bomb them smaller and glue them together somehow.

spacefractal

and yes its still look like and seen some of the puzzles look more compliced :-D.

There are few inspiration from Chips Challenge in my game as well in some levels.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

BdR

An update was released yesterday, and Czech translation was added to Snake Slider and Snake Slider Lite thanks to Luboslav Moza. See screenshots below. Also some minor puzzle tweaks, and the Lite version has hiss and click reduced for 2 sound effects (this update was already done in the full version)



Snake Slider (iPhone/iPad) https://itunes.apple.com/us/app/snake-slider/id450865171?mt=8
Snake Slider Lite (iPhone/iPad) https://itunes.apple.com/us/app/snake-slider-lite/id456056271?mt=8

Snake Slider (webOS) https://developer.palm.com/appredirect/?packageid=com.bdrgames.snakeslider
Snake Slider Lite (webOS) https://developer.palm.com/appredirect/?packageid=com.bdrgames.snakesliderlite

Beginner

I've just tested the lite version from the playstore on my medion tablet. Sadly it doesn't show the background graphics. The only things that I can see are the snakes and the interface.  :'(

BdR

Quote from: Beginner on 2012-Dec-02
I've just tested the lite version from the playstore on my medion tablet. Sadly it doesn't show the background graphics. The only things that I can see are the snakes and the interface.  :'(
I know, this is an issue with Android+GLBasic but it can be fixed.

When a GLBasic app starts for the first time on Android it copies all files in the "media" folder to the Android user data folder. Snake Slider has about 20MB of graphics files so this can take a while to copy. Android OS will detect that the app is not responding (same as on Windows) and will show a message "App not responding, close app?" or something like that. If the user closes the app during this first time start-up, the copying of files is cancelled and will not resume the next time the app is started. So then you have with half of the graphics files missing.

In short: to fix this and get a good install, go to settings, apps, select Snake Slider Lite and press "delete data" button. All local data (the graphics files) will be deleted and at next startup the app will notice that the folder does not exist and will start copying again. If a message "app not responding" pops up, do not close the app and keep pressing "wait" until the app starts. If that doesn't work then delete the app, reinstall and do not cancel the app at first time startup.

I think the Medion Tablet is relatively slow device, so there the problem might be more noticable. On something like a Galaxy S3 you might not notice it (I haven't tested it).

r0ber7

Hmm, this is something to remember...

Perhaps a small "installing... do not close program" message would help?

Beginner

#44
Quote from: BdR on 2012-Dec-03In short: to fix this and get a good install, go to settings, apps, select Snake Slider Lite and press "delete data" button. All local data (the graphics files) will be deleted and at next startup the app will notice that the folder does not exist and will start copying again. If a message "app not responding" pops up, do not close the app and keep pressing "wait" until the app starts. If that doesn't work then delete the app, reinstall and do not cancel the app at first time startup.

I think the Medion Tablet is relatively slow device, so there the problem might be more noticable. On something like a Galaxy S3 you might not notice it (I haven't tested it).

Sorry, but this doesn't solve the problem because:
1. I always "wait" until app starts
2. 400 EUR Medion is faster than my 79 EUR Trekstore Surftab breeze and has more RAM (on 79 EUR surftab your game runns very well)
3. same problem on nexus 7 of a friend of mine

Did you work with createscreen command?


BTW: I like your game very much. I'm a little jealous that I never have such good gameplay ideas myself.