From 8bee6dd30c42f115392ec3e21a678a69c384bd6e Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Mon, 23 May 2022 19:31:54 -0500 Subject: [PATCH] Pixel upscaling based on monitor size Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com> Co-authored-by: sigonasr2 --- 1x.png | Bin 0 -> 9690 bytes src/sig/DrawLoop.java | 10 ++++---- src/sig/RabiClone.java | 32 +++++++++++++++++++++--- src/sig/engine/Panel.java | 48 +++--------------------------------- src/sig/engine/Sprite.java | 1 + src/sig/objects/Player.java | 9 +++---- 6 files changed, 41 insertions(+), 59 deletions(-) create mode 100644 1x.png diff --git a/1x.png b/1x.png new file mode 100644 index 0000000000000000000000000000000000000000..66e874d4ee712d6a307706d103e1d06be773e833 GIT binary patch literal 9690 zcmeHtXH-*N&~5;w2~wm82t+zUAfbcw-g}cG29iJ^v=F-Vjv^>X?@f9Uq)L%0y%%XB zD2NCONRfJjZ@>5Z^R9Kje{ZtR$=Q3)JTvpm?7hycl_*_p6;fh)VgLX@s-~)_kNpK+ zUWEAAyPJ>C4*-Cq%*W6aqYw22x}cpANE951@pgd&;a*4t0N^!Okb->1+Ds90u}38> z@2bNT;SlP)yn2FHkZ8N%HDcr0TbplY3d1D|q_4l&A6Y$rqeF7gkWl*ExW7}!zBp`{ z!S}w*+4;UsQ@}SJudJ0lo!-TD#bw=(!mZL~-c}dx3jz3EEtsWG%=j;VN<;jm$Hsjh zp1`vYLvj)M_sR}sx1@AQDsP-i$p(Nnxre^QYTP{8Z)!ERt_;u)7$(u`-Sx^i*>@{3 zbcSc%P?#O-jc9|ka+2@!H_Up+|72i^U&-}&KjZtl#a3RfwRB=VVsl~4aH5{}EVO?; z1w<7ibS7~D z-!~;c(5Kc_34Ar5TJb{T%>K4P^8IrWe^O(eqN>ck8wB6d$lBc>?hbecoVHd@=oBV* zc;xJIgwm}@*;R+rAgKJ++Rj6XpYhO}4qx+){vb#jz&xM1u|4salYgY(jbJh@|M`!Z zvkl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4-~Qf+Ia}%`(DNIh`Dq`; zo+QUeTi@n7Usb|@4Nur6w`ON{v9uBkO~Gv=4Zo7alGUn)*ZpDjy<&%*%zAWf!?Kpq zvSO;*;#btK>l5a>3$r+zNS$@p^HCpq)LyN(Ajm2$TF7G$+iWDfT@pRlUWi5inm6(xy&!!ah%#KATJH|jhsk~CW@kBwJO)K3Q1|FN(hwC9hy=G_(jIWl zW?P!SF8?W1PG1o-J zny&S%v&J+ntyVEl@ys8imB&G&@O88xK}CGIbH3JeCGV&wQ8t>Cy|+pjra3!R;|i zKKa@U#w6%tW0bg#9}Nf=oZ%prX_Wry>`>7HuCL<4wBH>a^Uq}`SEp8oiU~7jVB+%2mHweOZ~_xBoc`VOw?0Pe3I&p8KLwlX@$-0HucdHZ^Wf?$>pn zudUr~lyXJ|-x=UP`%r8`R^U5FJ3T!W@cMMlwAw-sK<#_Cu`n7Jc^t(V&$jtxqp32s zHH2*MsPBaxYI|jCN9{VJZ)heS>n-U6f67=p.length) { + int index = (Y+(int)y)*RabiClone.BASE_WIDTH+X+(int)x; + if (index<0||index>=p.length||p[index]==sprite.getBi_array()[Y*sprite.getWidth()+X]) { continue; } else { Draw(p,index,sprite.getBi_array()[Y*sprite.getWidth()+X]); diff --git a/src/sig/RabiClone.java b/src/sig/RabiClone.java index 32e624e..459fee6 100644 --- a/src/sig/RabiClone.java +++ b/src/sig/RabiClone.java @@ -1,35 +1,52 @@ package sig; import javax.swing.JFrame; + import java.util.ArrayList; import java.util.List; import sig.engine.Panel; +import sig.objects.Player; import sig.engine.Object; +import java.awt.Toolkit; -public class RabiClone { +public class RabiClone{ public static final String PROGRAM_NAME="Sig's Java Project Template"; public static int UPCOUNT=0; public static Panel p; + public static JFrame f; public static List OBJ = new ArrayList(); + boolean newSizeSet=false; + + public static int BASE_WIDTH=512; + public static int BASE_HEIGHT=288; public static void main(String[] args) { - JFrame f = new JFrame(PROGRAM_NAME); + RabiClone r = new RabiClone(); + f = new JFrame(PROGRAM_NAME); + f.setResizable(false); + f.setUndecorated(true); + f.setSize(BASE_WIDTH,BASE_HEIGHT); //1024x576 (64x64) + ChooseBestRatio(); + p = new Panel(f); p.init(); f.add(p); - f.addComponentListener(p); f.addKeyListener(p); - f.setSize(1280,720); + f.setLocation((int)((Toolkit.getDefaultToolkit().getScreenSize().getWidth()-f.getWidth())/2), (int)((Toolkit.getDefaultToolkit().getScreenSize().getHeight()-f.getHeight())/2)); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); p.render(); + for (int i=0;i<10;i++) { + OBJ.add(new Player(p)); + } + long lastGameTime = System.nanoTime(); while (true) { long timePassed = System.nanoTime()-lastGameTime; @@ -44,4 +61,11 @@ public class RabiClone { } } } + private static void ChooseBestRatio() { + int multiplier=1; + while (f.getWidth()*(multiplier+1)getPanel().getWidth()|| - getY()<-this.getSprite().getHeight()||getY()>getPanel().getHeight()) { - setMarkedForDeletion(true); - } } @Override