该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

citingspace ::gdi_test::game_test::gemgem

function print_line(s)

endf

function FPS()

return 20 // frames per second to update the screen

endf

function WINDOWDEFAULTWIDTH()

return 1024 // width of the program's window, in pixels

endf

function WINDOWDEFAULTHEIGHT()

return 728 // height in pixels

endf

function BOARDWIDTH()

return 8 // how many columns in the board

endf

function BOARDHEIGHT()

return 8 // how many rows in the board

endf

function ScalingRatio()

return 2

endf

function GEMIMAGESIZE(windowWidth, windowHeight)

if windowWidth < windowHeight

return 64 * windowWidth / 640 // width & height of each space in pixels

else

return 64 * windowHeight / 640

endif

endf

function NUMGEMIMAGES()

// NUMGEMIMAGES is the number of gem types. You will need .png image

// files named gem0.png, gem1.png, etc. up to gem(N-1).png.

return 7 // game needs at least 5 types of gems to work

endf

function NUMMATCHSOUNDS()

// NUMMATCHSOUNDS is the number of different sounds to choose from when

// a match is made. The .wav files are named match0.wav, match1.wav, etc.

return 6

endf

function MOVERATE()

return 25 // 1 to 100, and 100 has to be its integer times. larger num means faster animations

endf

function DEDUCTSPEED()

return 800 // reduces score by 1 point every DEDUCTSPEED milliseconds.

endf

function PURPLE()

return [255, 0, 255]

endf

function LIGHTBLUE()

return [170, 190, 255]

endf

function BLUE()

return [0, 0, 255]

endf

function RED()

return [255, 100, 100]

endf

function BLACK()

return [0, 0, 0]

endf

function BROWN()

return [85, 65, 0]

endf

function HIGHLIGHTCOLOR()

return PURPLE() // color of the selected gem's border

endf

function BGCOLOR()

return LIGHTBLUE() // background color on the screen

endf

function GRIDCOLOR()

return BLUE() // color of the game board

endf

function GAMEOVERCOLOR()

return RED() // color of the "Game over" text.

endf

function GAMEOVERBGCOLOR()

return BLACK() // background color of the "Game over" text.

endf

function SCORECOLOR()

return BROWN() // color of the text for the player's score

endf

// The amount of space to the sides of the board to the edge of the window

// is used several times, so calculate it once here and store in variables.

function XMARGIN(windowWidth, windowHeight)

return floor((windowWidth - GEMIMAGESIZE(windowWidth, windowHeight) * BOARDWIDTH()) / 2)

endf

function YMARGIN(windowWidth, windowHeight)

return floor((windowHeight - GEMIMAGESIZE(windowWidth, windowHeight) * BOARDHEIGHT()) / 2)

endf

// constants for direction values

function UP()

return "up"

endf

function DOWN()

return "down"

endf

function LEFT()

return "left"

endf

function RIGHT()

return "right"

endf

function EMPTY_SPACE()

return -1// an arbitrary, nonpositive value

endf

function ROWABOVEBOARD()

return "row above board" // an arbitrary, noninteger value

endf

Help

This program has "gem data structures", which are basically dictionaries

with the following keys:

'x' and 'y' - The location of the gem on the board. 0,0 is the top left.

There is also a ROWABOVEBOARD row that 'y' can be set to,

to indicate that it is above the board.

'direction' - one of the four constant variables UP, DOWN, LEFT, RIGHT.

This is the direction the gem is moving.

'imageNum' - The integer index into GEMIMAGES to denote which image

this gem uses.

Endh

function start_gemgem()

variable DISPLAYSURF, GEMIMAGES, BOARDRECTS

// Initial set up

DISPLAYSURF = open_screen_display("Gem gem", BGCOLOR(), true, [WINDOWDEFAULTWIDTH(), WINDOWDEFAULTHEIGHT()], false)

variable windowWidth = get_display_size(DISPLAYSURF)[0], windowHeight = get_display_size(DISPLAYSURF)[1]

variable shrinkingRatio = 1/ScalingRatio()

variable xMargin = XMARGIN(windowWidth, windowHeight)

variable yMargin = YMARGIN(windowWidth, windowHeight)

variable gemImgSize = GEMIMAGESIZE(windowWidth, windowHeight)

variable mvRate = MOVERATE()

// Load the images of the GEMs

GEMIMAGES = alloc_array([NUMGEMIMAGES()])

@build_asset copy_to_resource(get_upper_level_path(get_src_file_path()), "charts")

for variable idx = 1 to NUMGEMIMAGES()

variable gemImage

if is_mfp_app()

gemImage = load_image_from_zip(get_asset_file_path("resource"), "charts/gem" + idx + ".png", 1)

else

gemImage = load_image(get_upper_level_path(get_src_file_path()) + "gem" + idx + ".png")

endif

variable gemImageSize = get_image_size(gemImage)

GEMIMAGES[idx - 1] = clone_image(gemImage, 0, 0, gemImageSize[0], gemImageSize[1], gemImgSize * shrinkingRatio, gemImgSize * shrinkingRatio)

next

// No need to load the sounds. Sounds can be loaded on the spot.

// Create pygame.Rect objects for each board space to

// do board-coordinate-to-pixel-coordinate conversions.

BOARDRECTS = alloc_array([BOARDWIDTH(), BOARDHEIGHT()])

for variable x = 0 to BOARDWIDTH() - 1

for variable y = 0 to BOARDHEIGHT() - 1

BOARDRECTS[x,y] = [xMargin + (x * gemImgSize), yMargin + (y * gemImgSize), _

gemImgSize, gemImgSize]

next

next

variable up = UP(), down = DOWN(), left = LEFT(), right = RIGHT()

variable rowAboveBoard = ROWABOVEBOARD()

variable boardImageDisplay = open_image_display(null)

set_display_size(boardImageDisplay, windowWidth, windowHeight)

for variable x = 0 to BOARDWIDTH() - 1

for variable y = 0 to BOARDHEIGHT() - 1

draw_rect("gemgem", boardImageDisplay, [BOARDRECTS[x][y][0], BOARDRECTS[x][y][1]], _

BOARDRECTS[x][y][2], BOARDRECTS[x][y][3], GRIDCOLOR(), 1)

next

next

update_display(boardImageDisplay)

variable boardImage = get_display_snapshot(boardImageDisplay, false)

set_display_bgrnd_image(DISPLAYSURF, boardImage, 0)

while run_game(DISPLAYSURF, GEMIMAGES, BOARDRECTS, gemImgSize, windowWidth, windowHeight, _

xMargin, yMargin, mvRate, up, down, left, right, rowAboveBoard)

loop

shutdown_display(boardImageDisplay)

endf

// for gem, a 3-element or 4-element array stores gem information. In particular, gem[0] is imageNum, gem[1] is x, gem[2] is y, gem[3] is direction.

// for point, a 3-element array stores point information. In particular, point[0] is point, point[1] is x, point[2] is y.

function run_game(DISPLAYSURF, GEMIMAGES, BOARDRECTS, gemImgSize, windowWidth, windowHeight, xMargin, yMargin, mvRate, up, down, left, right, rowAboveBoard)

// Plays through a single game. When the game is over, this function returns.

// initalize the board

variable gameBoard = get_blank_board()

variable score = 0

variable gemsImageAndDisplay = init_Board_And_Animate(DISPLAYSURF, GEMIMAGES, BOARDRECTS, gameBoard, windowWidth, windowHeight, mvRate) // drop the initial gems.

variable gemsImage = gemsImageAndDisplay[0]

variable gemsImageDisplay = gemsImageAndDisplay[1]

// now gemsImageDisplay is updated.

// initialize variables for the start of a new game

variable firstSelectedGem = Null

variable lastMouseDownX = Null

variable lastMouseDownY = Null

variable gameIsOver = False

variable lastScoreDeduction = now()

variable clickContinueTextSurf = Null

variable infoNum = 0, infoX = 1, infoY = 2, infoDirect = 3

variable shrinkingRatio = 1/ScalingRatio(), scaledRatio = scalingRatio()

while true // main game loop

drop_old_painting_requests("gemgem", DISPLAYSURF)

variable clickedSpace = null

do

variable giEvent = pull_event(DISPLAYSURF)

if giEvent == Null

// no event to handle

break

elseif get_event_type_name(giEvent) == "GDI_CLOSE"

// quit

return false

elseif get_event_type_name(giEvent) == "POINTER_UP"

if gameIsOver

return true // after games ends, click to start a new game

endif

// we do not consider drag.

clickedSpace = check_For_Gem_Click([lastMouseDownX, lastMouseDownY], BOARDRECTS)

elseif get_event_type_name(giEvent) == "POINTER_DOWN"

// this is the start of a mouse click or mouse drag

lastMouseDownX = get_event_info(giEvent, "x")

lastMouseDownY = get_event_info(giEvent, "y")

endif

until false

if and(clickedSpace != Null, firstSelectedGem == Null)

......

科学计算机怎么编程游戏,官泄 可编程科学计算器开发游戏相关推荐

  1. 科学计算机如何输入x的n次方,科学计算器使用-20210321170247.docx-原创力文档

    第一章科学计算器使用 第一节计算器下载与安装及标准型的界面打开简介 科学计算器在 华军软件园 > 教育教学 > 理科工具 > 科学计算器多功能版可下载安装. 科学计算器在计算机中本身 ...

  2. 计算器也是一种计算机游戏,脑洞大开 一款名曰计算器的游戏评测

    今年的天气可谓百年难遇,炎热的天气让在家吹空调成为最大的享受,我们的假期就在不知不觉中过去了一半.暑假最闹心的是什么,当然是老师家长布置的作业了,偶尔找时间偷玩一下都会被说的不行~.~. 今年的天气可 ...

  3. 计算机的shuzi游戏,脑洞大开 一款名曰计算器的游戏评测

    原标题:脑洞大开 一款名曰计算器的游戏评测 今年的天气可谓百年难遇,炎热的天气让在家吹空调成为最大的享受,我们的假期就在不知不觉中过去了一半.暑假最闹心的是什么,当然是老师家长布置的作业了,偶尔找时间 ...

  4. python写游戏需要安装什么软件_python开发游戏的前期准备

    本文章面向有一定基础的python学习者,使用Pygame包开发一款简单的游戏 首先打开命令行,使用PyPI下载Pygame包(输入命令pip install pygame) 打开python编辑器( ...

  5. python做流程图_少儿Python编程_第十四讲:开发游戏

    无论哪一种编程语言,实现图形界面程序的方法都大同小异.本讲介绍用Python开发小游戏的方法,从中学习使用Python编写图形界面的程序,图形图像的基础知识,以及在图形界面程序中与用户交互.最后部分还 ...

  6. 体积的2 3科学计算机怎么算,小学三年级上册科学第2课-测量体积教案-冀人版

    以下为<小学三年级上册科学第2课-测量体积教案-冀人版>的无排版文字预览,完整格式请下载 下载前请仔细阅读文字预览以及下方图片预览.图片预览是什么样的,下载的文档就是什么样的. 第2课 测 ...

  7. 科学计算机复利现值怎么计算公式,怎么用科学计算器算年金现值和复利现值是那个......

    2016-06-03 00:29最佳答案 1,运用年金终值公式 年金终值(普通年金终值)指一定时期内,每期期末等额收入或支出的本利和,也就是将每一期的金额,按复利换算到最后一期期末的终值,然后加总,就 ...

  8. 苹果科学计算机不好用,嫌弃iPhone自带的计算器没用?那是因为你不知道这些小技巧!...

    用iPhone手机的朋友,你用过iPhone自带的计算器吗? 教授身边有很多苹果用户觉得iPhone手机上自带的计算器APP不好用,真的是这样吗?其实,平时在使用手机的过程中,有很多关于手机的小秘密我 ...

  9. 科学计算机eq7,HiPER Calc Pro(多功能科学计算器)

    HiPER Calc Pro是一款多功能科学计算器,不仅仅可以转换各种的变数还能计算非常复杂的内容,操作简单方便,而且特别的精准,需要经常进行精密计算的朋友赶紧来下载HiPER Calc Pro试试吧 ...

最新文章

  1. Python字符串方法用示例解释
  2. java的drawstring_java-Graphics.drawString()未绘制
  3. 禁止USB存储设备。
  4. 2018 前端面试题(不定期更新)
  5. 字节跳动 设计模式 pdf_凭这份pdf我拿下了美团、字节跳动、阿里、小米等大厂的offer...
  6. 洛谷 P2515 [HAOI2010]软件安装 解题报告
  7. Python基础学习----Requests获取url请求时间:
  8. Python 模拟简单区块链
  9. Django 千锋培训的学习笔记
  10. 生活中计算机自动控制原理的应用,《自动控制原理》虚拟实验系统在教学中的应用...
  11. 2022-07-04-5万字长文说清楚到底什么是“车规级”
  12. SpringBoot在使用测试的时候是否需要@RunWith?
  13. java+ElementUI前后端分离旅游项目第六天 移动端开发下
  14. 2020秋季校园招聘深信服、噢易云、绿盟面筋
  15. 龙芯Fedora21平台制作feodra21-tools docker镜像
  16. import_meta_graph 和 replicate_model_fn
  17. java的单行注释符是_Java 程序中的单行注释符是( ),多行注释符是( )_学小易找答案...
  18. 面试官:递归是个什么东东?
  19. cdrx8如何批量导出jpg_cdr x8批量导出插件
  20. 阿里云短信服务——短信发送验证码

热门文章

  1. gitclone 一个tag的地址_获取Url地址中参数的几种方法
  2. 开源mes系统_如何让iMES系统快速落地变得so easy?
  3. java程序设计_Java程序设计--final(笔记)
  4. Linux内核信号量:二值信号量/互斥信号量,计数信号量,读写信号量
  5. DPDK服务核心(coremask)
  6. 一个简单的javascript时钟程序
  7. Mysql的日期查询方法
  8. android-6.0 新功能介绍(Marshmallow)
  9. 傲游浏览器linux傲游源,Ubuntu下安装遨游浏览器
  10. Docker实践(七)部署SpringBoot微服务