Magic 4x4

Advanced game related topics
pjay
Enthusiast
Enthusiast
Posts: 251
Joined: Thu Mar 30, 2006 11:14 am

Re: Magic 4x4

Post by pjay »

It was a black screen for me to, apart from the score - I managed 336 in the darkness...

Disabling autostretch (or the DPI awareness switch) resolved the issue; being able to see what I'm doing I managed to score... 258! I'm clearly better off with my eyes shut. :lol:

Nice, thanks for posting.
threedslider
Enthusiast
Enthusiast
Posts: 377
Joined: Sat Feb 12, 2022 7:15 pm

Re: Magic 4x4

Post by threedslider »

@pjay : True for disabling the DPI they work on all version from 6.04 to 6.21 beta9 ! Thank you a lot :D :shock:
dige
Addict
Addict
Posts: 1391
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Re: Magic 4x4

Post by dige »

Score: 886

What kind of game is this? I played it purely intuitively without knowing what to do. I could watch myself play - crazy! :shock: :D
"Daddy, I'll run faster, then it is not so far..."
#NULL
Addict
Addict
Posts: 1497
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: Magic 4x4

Post by #NULL »

On linux something doesn't work with the GrabSprite(). When I use CreateSprite() instead, I can see the numbered squares:
(around line number ~51)

Code: Select all

For i=1 To 16
  nb$=Str(nb)
  
  ;StartDrawing(ScreenOutput())
  CreateSprite(i, zoom/4,zoom/4)
  StartDrawing(SpriteOutput(i))
  
  DrawingMode(1)
  Box(0,0,zoom/4-1,zoom/4-1,RGB(188,188,188))
  
  For y=4 To zoom/4-6
    For x=4 To zoom/4-6
      Plot(x,y,RGB(SPH(1,i)+Random(x/2),SPH(2,i)+Random(y/2),SPH(3,i)+Random((x+y)/3))) 
    Next
  Next
  
  DrawingFont(Police)
  DrawText(zoom/8-TextWidth(nb$)/2,zoom/8-TextHeight(nb$)/2, nb$, RGB(255,255,255))
  StopDrawing()
  ;GrabSprite(i,0,0,zoom/4,zoom/4)
  nb*2
Next
At first I thought it's a font problem, but Arial actually worked for me. But maybe you have to try a different font on you system if you still can't see something:
(around line 19)

Code: Select all

Police = LoadFont(0, "ubuntu", 24);zoom/25)
Police2 = LoadFont(1, "terminal", zoom/70)
Police3 = LoadFont(2, "terminal", zoom/23)
Police4 = LoadFont(3, "terminal", zoom/12)
Debug IsFont(0)
Debug Police
User avatar
SPH
Enthusiast
Enthusiast
Posts: 561
Joined: Tue Jan 04, 2011 6:21 pm

Re: Magic 4x4

Post by SPH »

#NULL wrote: Thu May 15, 2025 8:04 am On linux something doesn't work with the GrabSprite(). When I use CreateSprite() instead, I can see the numbered squares:
(around line number ~51)

Code: Select all

For i=1 To 16
  nb$=Str(nb)
  
  ;StartDrawing(ScreenOutput())
  CreateSprite(i, zoom/4,zoom/4)
  StartDrawing(SpriteOutput(i))
  
  DrawingMode(1)
  Box(0,0,zoom/4-1,zoom/4-1,RGB(188,188,188))
  
  For y=4 To zoom/4-6
    For x=4 To zoom/4-6
      Plot(x,y,RGB(SPH(1,i)+Random(x/2),SPH(2,i)+Random(y/2),SPH(3,i)+Random((x+y)/3))) 
    Next
  Next
  
  DrawingFont(Police)
  DrawText(zoom/8-TextWidth(nb$)/2,zoom/8-TextHeight(nb$)/2, nb$, RGB(255,255,255))
  StopDrawing()
  ;GrabSprite(i,0,0,zoom/4,zoom/4)
  nb*2
Next
Thank you very much for this correction. If it's okay with everyone, I'll correct my code with your routines.
A quick question: what about the different DPIs despite your corrected code?

PS : i dont have Linux (because : windows rule) :mrgreen:

!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Portable LENOVO ideapad 110-17ACL 64 bits
Version de PB : 6.12LTS - 64 bits
miso
Enthusiast
Enthusiast
Posts: 410
Joined: Sat Oct 21, 2023 4:06 pm
Location: Hungary

Re: Magic 4x4

Post by miso »

Hmm, if it's not linux, but DPI problem, changing only line 17 to this might solve everything:
(openscreen should remain as it is)

Code: Select all

ExamineDesktops()
OpenWindow(0,0,0,DesktopUnscaledX(zoom),DesktopUnscaledY(zoom+zoom/10),"Magic 4x4",#PB_Window_ScreenCentered);|#PB_Window_SystemMenu)
If someone would be able to test this who had glitch, that would be also helpful as a learning experience for me.
User avatar
SPH
Enthusiast
Enthusiast
Posts: 561
Joined: Tue Jan 04, 2011 6:21 pm

Re: Magic 4x4

Post by SPH »

1000 exactly

Image

!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Portable LENOVO ideapad 110-17ACL 64 bits
Version de PB : 6.12LTS - 64 bits
BarryG
Addict
Addict
Posts: 4128
Joined: Thu Apr 18, 2019 8:17 am

Re: Magic 4x4

Post by BarryG »

I have no idea how to play this or what to do. The "instructions" on line 5 don't explain jack.
User avatar
SPH
Enthusiast
Enthusiast
Posts: 561
Joined: Tue Jan 04, 2011 6:21 pm

Re: Magic 4x4

Post by SPH »

BarryG wrote: Thu May 15, 2025 11:27 am I have no idea how to play this or what to do. The "instructions" on line 5 don't explain jack.
The goal of the game is to add two identical numbers by pressing them together using the arrow keys on your keyboard.
Escape to exit.

New version (1.1c) on post 1.

!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Portable LENOVO ideapad 110-17ACL 64 bits
Version de PB : 6.12LTS - 64 bits
User avatar
Mindphazer
Enthusiast
Enthusiast
Posts: 456
Joined: Mon Sep 10, 2012 10:41 am
Location: Savoie

Re: Magic 4x4

Post by Mindphazer »

BarryG wrote: Thu May 15, 2025 11:27 am I have no idea how to play this or what to do. The "instructions" on line 5 don't explain jack.
It's just a reboot of 2048 game :
https://en.wikipedia.org/wiki/2048_(video_game)

viewtopic.php?p=445750#p445750

viewtopic.php?p=526522&hilit=2048+game#p526522
MacBook Pro 16" M4 Pro - 24 Gb - MacOS 15.4.1 - Iphone 15 Pro Max - iPad at home
...and unfortunately... Windows at work...
User avatar
NicTheQuick
Addict
Addict
Posts: 1504
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: Magic 4x4

Post by NicTheQuick »

Version 1.1c works now. But I think there is a bug. If you move into a direction that does not change the field, there still will be added two new pieces. Therefore I think if there is a direction that does not change the field no new pieces should be added.

Btw. here's my first try:
Image
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
User avatar
SPH
Enthusiast
Enthusiast
Posts: 561
Joined: Tue Jan 04, 2011 6:21 pm

Re: Magic 4x4

Post by SPH »

NicTheQuick wrote: Thu May 15, 2025 2:13 pm Version 1.1c works now. But I think there is a bug. If you move into a direction that does not change the field, there still will be added two new pieces. Therefore I think if there is a direction that does not change the field no new pieces should be added.
Are you sure it adds two pieces even if the chosen direction doesn't move any pieces?
I coded the game so that it only adds one piece. I'm sure of it. To convince yourself, take a screenshot before and after a turn and look closely...

By the way: I'm amazed by your score! GG

!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Portable LENOVO ideapad 110-17ACL 64 bits
Version de PB : 6.12LTS - 64 bits
User avatar
moulder61
Enthusiast
Enthusiast
Posts: 188
Joined: Sun Sep 19, 2021 6:16 pm
Location: U.K.

Re: Magic 4x4

Post by moulder61 »

@SPH

It works OK for me in Linux using PB6.11 LTS b2.

It adds a new number even if your key press doesn't actually move anything, but I'm not sure if that's a bug or a feature? :wink:

I could see it being useful tactically, occasionally.

Moulder.
"If it ain't broke, fix it until it is!

This message is brought to you thanks to SenselessComments.com

My PB stuff for Linux: "https://u.pcloud.link/publink/show?code ... z3MR0T3jyV
User avatar
NicTheQuick
Addict
Addict
Posts: 1504
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: Magic 4x4

Post by NicTheQuick »

SPH wrote: Thu May 15, 2025 3:28 pm
NicTheQuick wrote: Thu May 15, 2025 2:13 pm Version 1.1c works now. But I think there is a bug. If you move into a direction that does not change the field, there still will be added two new pieces. Therefore I think if there is a direction that does not change the field no new pieces should be added.
Are you sure it adds two pieces even if the chosen direction doesn't move any pieces?
I coded the game so that it only adds one piece. I'm sure of it. To convince yourself, take a screenshot before and after a turn and look closely...

By the way: I'm amazed by your score! GG
Yes, sorry for that. The original one on a 5x5 grid usually adds 2 pieces. I just confused it with yours. Your code only adds one piece.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
User avatar
SPH
Enthusiast
Enthusiast
Posts: 561
Joined: Tue Jan 04, 2011 6:21 pm

Re: Magic 4x4

Post by SPH »

No problemo :wink:

!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Portable LENOVO ideapad 110-17ACL 64 bits
Version de PB : 6.12LTS - 64 bits
Post Reply