c语言写台球游戏,OpenGL版 3D台球 (原创,Basic实现) 申精!

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

' Physics constants

const ballWallBounce# = .7

const ballPinBounce# = .4

const ballBallBounce# = .7

const friction# = 0.005

const debug = false

const ballRadius# = 5.11

' Ball drawing constants

const xSlices = 20

const ySlices = 10

' Game structures

struc SProcessed

dim frame, ballIndex

endstruc

struc SBounds

dim x1, y1, x2, y2

endstruc

struc SBall

dim pos#(1)

dim vel#(1)

dim radius#

dim active ' True if still active. False = removed from game (e.g sunk)

dim moving

dim SProcessed processed

dim SBounds bounds

dim number ' 0 = cue ball, > 0 = number ball

dim angle#(3)(3)

dim roll#(3)(3), invRoll#(3)(3)

endstruc

struc SWall

dim pos#(1) ' Point where wall starts

dim pin ' Place an implied pin at pos#

dim T#(1) ' Unit tangent vector

dim N#(1) ' Unit normal vector

dim l# ' Length

dim sink ' True if ball sinks when it hits this wall

dim SProcessed wallProcessed

dim SProcessed pinProcessed

dim SBounds bounds

endstruc

struc SPlayer

dim name$

dim ballType ' (OVERS/UNDERS etc)

endstruc

' Ball drawing structures

struc SVertex

dim pos#(2)

dim norm#(2)

dim tex#(1)

endstruc

' Optimisation structures

' Table is grouped into a grid. Each square contains a list of

' walls, pins and balls contained inside it.

struc SWallLink

' Also used as a pin link

dim SWall &wall

dim SWallLink &nextLink

endstruc

struc SBallLink

dim SBall &ball

dim SBallLink &nextLink

endstruc

struc SGridCell

dim SWallLink &walls

dim SWallLink &pins

dim SBallLink &balls

dim SGridCell &nextCell

dim frame

endstruc

const gridXcells = 15, gridYcells = 23

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值