Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Today I learned loops are slow
#5
Yikes both forumlas were flawed, glad I checked my formulas. Turns out we only need SPR's Sprites per Row:
    sheetx = (index Mod SPRow) * SW
    sheety = Int(index / SPRow) * SH

OK here is snap of the sprite sheet:
   

We will display the top row of cards by index numbers from 0 to 13

Code: (Select All)
_Title "Card Sprites by Index demo" 'bplus 2025-11-27
CardDeck = _LoadImage("Cards.png")
If CardDeck = -1 Then Print "Cards.png failed to load, bye!": End

' this set
SW = 72: SH = 96: SPRow = 14: SPCol = 4
Screen _NewImage(3 * SW, 3 * SH, 32)  ' magnify each card 3X's its pixel size

For index = 0 To 13
    Cls
    sheetx = (index Mod SPRow) * SW
    sheety = Int(index / SPRow) * SH
    _PutImage , CardDeck, 0, (sheetx, sheety)-Step(SW, SH)
    _Delay .5
Next

Change index = 14 to 27 and see the next row... 28 to 41 next and 42 to 55 for last.

zip with card sheet and code:


Attached Files
.zip   Cards off sprite sheet demo.zip (Size: 47.47 KB / Downloads: 25)
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply


Messages In This Thread
Today I learned loops are slow - by CMR - 11-27-2025, 05:20 AM
RE: Today I learned loops are slow - by bplus - 11-27-2025, 02:09 PM
RE: Today I learned loops are slow - by CMR - 11-27-2025, 05:20 PM
RE: Today I learned loops are slow - by bplus - 11-27-2025, 06:27 PM
RE: Today I learned loops are slow - by bplus - 11-27-2025, 07:17 PM
RE: Today I learned loops are slow - by CMR - 11-27-2025, 08:35 PM
RE: Today I learned loops are slow - by bplus - 11-27-2025, 09:17 PM
RE: Today I learned loops are slow - by Pete - 11-27-2025, 10:52 PM
RE: Today I learned loops are slow - by CMR - 11-28-2025, 01:58 AM
RE: Today I learned loops are slow - by TDarcos - 12-20-2025, 02:15 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  I have learned something new: how to get a run-time syntax error TDarcos 2 970 10-02-2024, 07:04 PM
Last Post: TDarcos
  A little bit of spark fun today TerryRitchie 2 839 05-18-2024, 12:59 AM
Last Post: bobalooie
  Loops alternate recursive ways bplus 10 2,032 02-01-2023, 02:05 PM
Last Post: Dimster

Forum Jump:


Users browsing this thread: 1 Guest(s)