博文

目前显示的是 一月, 2024的博文

趙柏翰VS code俄羅斯方塊maintain維護物件object

图片
js程式碼 let canvas = document.getElementById("tetris"); let scoreboard = document.getElementById("score"); let ctx = canvas.getContext("2d"); ctx.scale(30,30); const FOUR = [ //設定 [[0,1,0,0],[0,1,0,0],[0,1,0,0],[0,1,0,0]],//I紅 [[0,1,0], [0,1,0], [1,1,0]], //J橘 [[0,1,0], [0,1,0], [0,1,1]], //L黃 [[1,1,0], [0,1,1], [0,0,0]], //Z綠 [[0,1,1], [1,1,0], [0,0,0]], //S藍 [[1,1,1], [0,1,0], [0,0,0]], //T靛 [[1,1], [1,1],]]; //M紫,正方形,以上共7個 const COLORS = [ "lightgray","red","orange","yellow","darkgreen","blue","indigo","purple"]; const ROWS = 20; //列數ROWS const COLS = 10; //欄數COLumnS let grid = generateGrid(); //呼叫函數產生20x10格子 let fallingPieceObj = null; let score = 0; setInterval(newGameState,200); //...

趙柏翰Java程式設計

图片
import java.awt.*; import java.awt.geom.Line2D; import javax.swing.*; public class Options { public static void main(String[] args) { JFrame frame = new JFrame("趙柏翰Java繪製選擇權到期日損益"); Container cp = frame.getContentPane(); cp.add(new JComponent() { public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setStroke(new BasicStroke(2));//stroke中風,筆觸 g2.setColor(Color.BLUE); g2.setFont(new Font("monospaced", Font.BOLD, 30)); g2.drawString("買入賣權到期日損益",0,120); g2.draw(new Line2D.Float(0, 0, 100, 100)); g2.draw(new Line2D.Float(100, 100, 200, 100)); g2.drawString("買入買權到期日損益",300,120); g2.draw(new Line2D.Float(300, 100, 400, 100)); g2.draw(new Line2D.Float(400, 100, 500, 0)); g2.drawString("賣出賣權到期日損益",0,180); ...