Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
- ; #Warn ; Enable warnings to assist with detecting common errors.
- SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
- SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
- #Include,<hellbents_gdip>
- SetBatchLines,-1
- #MaxHotkeysPerInterval,10000000000
- popUp:=Layered_Window_SetUp(4,0,0,A_ScreenWidth,A_ScreenHeight,1,"Alwaysontop")
- ;~ back1:=new BackClass(50,50,560,560,50,"0000af","000000",popup)
- ;~ ball1:= New BallClass(350,350,10,"a00000",5,7,0.001,back1)
- ;~ ballz1:=new ballz(back1,"00ff00",6,0.001)
- ;~ ballz1.add(100,100,50,90)
- ;~ ballz1.add(100,100,50,0)
- ;~ str:={x:17,y:17,s:20}
- ;~ block1:=new BlockClass(200,200,25,5,"00ff00","ffffff",back1,3,{x:17,y:17,s:20},16)
- blocks1:=New BlockS(16,4,"00ff00","ffffff",back1,4,{x:17,y:17,s:20})
- ;~ blocks1.add(100,100,16,1)
- ;~ blocks1.add(200,200,16,2)
- matrix1:= new Matrix(15,15,BlockS1.w*2 + 2,BlockS1)
- matrix1.setBack(50,50,50,"0000af","000000",popup)
- blocks1.back:=matrix1.back
- matrix1.add(1,1,16)
- matrix1.add(2,0,16)
- ballz1:=new ballz(matrix1.back,"00ff00",6,0.0001)
- n:=20
- loop % n {
- Random,angle,30,150
- random,v,10,35
- ballz1.add(400,400,v,angle)
- }
- launch1:=new Launch(ballz1,matrix1.back)
- launch1.firstTouch:=1
- launch1.lastLaunched:=n
- tt:=0
- SetTimer,matrixLoop,25
- return
- targetLoop:
- loop {
- if(GetKeyState("lbutton") = 0)
- break
- ToolTip,release lbutton
- }
- ToolTip
- loop {
- Gdip_GraphicsClear(popUp.g)
- matrix1.back.draw()
- matrix1.BlockS.draw()
- ballz1.draw()
- massVangle:=launch1.drawArrow(popup.g)
- UpdateLayeredWindow(popUp.hwnd, popUp.hdc, popUp.x, popUp.y, popUp.w, popUp.h)
- if(GetKeyState("lbutton") )
- break
- }
- return
- 8::
- SetTimer,matrixLoop,-1
- gosub allToTouchLoop
- SetTimer,matrixLoop,25
- return
- allToTouchLoop:
- Loop 100 {
- loop % floor(a_index/1.1+1) {
- Launch1.allToTouch()
- }
- Gdip_GraphicsClear(popUp.g)
- matrix1.back.draw()
- matrix1.BlockS.draw()
- ballz1.draw()
- UpdateLayeredWindow(popUp.hwnd, popUp.hdc, popUp.x, popUp.y, popUp.w, popUp.h)
- }
- return
- blocksLoop:
- Gdip_GraphicsClear(popUp.g)
- blocks1.draw()
- UpdateLayeredWindow(popUp.hwnd, popUp.hdc, popUp.x, popUp.y, popUp.w, popUp.h)
- return
- loopSmooth:
- Gdip_GraphicsClear(popUp.g)
- matrix1.back.draw()
- matrix1.BlockS.draw()
- ballz1.draw()
- UpdateLayeredWindow(popUp.hwnd, popUp.hdc, popUp.x, popUp.y, popUp.w, popUp.h)
- return
- moveBlocksLoop:
- loop 25 {
- matrix1.matrixMoveSmooth(25)
- gosub loopSmooth
- }
- matrix1.matrixMove()
- matrix1.ranadd()
- return
- matrixLoop:
- if(Launch1.lastLaunched = ballz1.ArroWballz.length() && Launch1.iflaunch() = 1){
- SetTimer,matrixLoop,-1
- gosub moveBlocksLoop
- gosub allToTouchLoop
- gosub targetLoop
- Launch1.lastLaunched:=0
- SetTimer,matrixLoop,25
- }
- tt++
- if(mod(tt,5) = 0)
- launch1.launchEm(massVangle.v,massVangle.angle)
- launch1.touch()
- Gdip_GraphicsClear(popUp.g)
- matrix1.moveBallz(10,ballz1.ArroWballz)
- matrix1.back.draw()
- matrix1.BlockS.draw()
- ballz1.draw()
- UpdateLayeredWindow(popUp.hwnd, popUp.hdc, popUp.x, popUp.y, popUp.w, popUp.h)
- return
- gameLoop:
- ballz1.launch()
- Gdip_GraphicsClear(popUp.g)
- back1.draw()
- degree:=100
- for i,value in ballz1.ArroWballz {
- value.g/=degree
- value.vx/=degree
- value.vy/=degree
- }
- for i,value in ballz1.ArroWballz {
- loop % degree {
- value.move()
- value.bounce()
- }
- }
- for i,value in ballz1.ArroWballz {
- value.g*=degree
- value.vx*=degree
- value.vy*=degree
- }
- for i,value in ballz1.ArroWballz
- value.draw()
- UpdateLayeredWindow(popUp.hwnd, popUp.hdc, popUp.x, popUp.y, popUp.w, popUp.h)
- return
- class BlockClass {
- __New(x,y,w,r,colourOut,colourIn,back,dr,str,point){
- this.x:=x,this.y:=y,this.r:=r,this.w:=w,this.colourOut:=colourOut,this.colourIn:=colourIn,this.g:=back.g,this.dr:=dr,this.str:=str
- back:=this.back,this.ballz:=[]
- v:=0,g:=0,angle:=0
- colour:="I_need_more_hours_with_U"
- x:=this.x - this.w + r , y:=this.y - this.w + r
- this.ballz.insert(new BallClass(X,Y,R,COLOUR,V,ANGLE,G,BACK))
- x:=this.x + this.w - r , y:=this.y - this.w + r
- this.ballz.insert(new BallClass(X,Y,R,COLOUR,V,ANGLE,G,BACK))
- x:=this.x - this.w + r , y:=this.y + this.w - r
- this.ballz.insert(new BallClass(X,Y,R,COLOUR,V,ANGLE,G,BACK))
- x:=this.x + this.w - r , y:=this.y + this.w - r
- this.ballz.insert(new BallClass(X,Y,R,COLOUR,V,ANGLE,G,BACK))
- THIS.POINT:=point
- }
- draw(){
- pBrushIn:=new_brush(this.colourIn), pBrushOut:=new_brush(this.colourOut), dr:=this.dr
- Gdip_FillRoundedRectangle(this.g, pBrushOut, this.x - this.w, this.y -this.w, 2*this.w, 2*this.w , this.r)
- Gdip_FillRoundedRectangle(this.g, pBrushIn, this.x - this.w + dr, this.y -this.w + dr, 2*this.w - 2*dr, 2*this.w -2*dr , this.r)
- string:="x" this.x - this.str.x " y" this.y - this.str.y " s" this.str.s " cff000000 "
- gdip_TextToGraphics(THIS.g, this.point,String, "Segoe Print")
- }
- bump(ballAttacker){
- if(this.inside(ballAttacker)){
- f1x:=(ballAttacker.x >= this.x - this.w + this.r )
- f2x:=(ballAttacker.x <= this.x + this.w - this.r )
- fx:=(f1x && f2x)
- f1Y:=(ballAttacker.y >= this.y - this.w + this.r )
- f2y:=(ballAttacker.y <= this.y + this.w - this.r )
- fy:=(f1y && f2y)
- if(fx || fy){
- if(ballAttacker.vx > 0 && fy )
- ballAttacker.x := this.x - this.w - ballAttacker.r - 1 ,ballAttacker.vx:=-ballAttacker.vx
- else if(ballAttacker.vx < 0 && fy)
- ballAttacker.x := this.x + this.w + ballAttacker.r + 1, ballAttacker.vx:=-ballAttacker.vx
- if(ballAttacker.vy > 0 && fx)
- ballAttacker.y := this.y - this.w - ballAttacker.r - 1 ,ballAttacker.vy:=-ballAttacker.vy
- else if(ballAttacker.vy < 0 && fx )
- ballAttacker.y := this.y + this.w + ballAttacker.r + 1, ballAttacker.vy:=-ballAttacker.vy
- }
- else {
- loop 4 {
- ballAttacker.bump(this.ballz[A_Index])
- }
- }
- }
- }
- inside(ball){
- f1x:=(ball.x >= this.x - this.w - ball.r )
- f2x:=(ball.x <= this.x + this.w + ball.r)
- f1y:=(ball.y >= this.y - this.w - ball.r )
- f2y:=(ball.y <= this.y + this.w + ball.r)
- if(f1x && f2x && f1y && f2y)
- return true
- return false
- }
- }
- class BlockS {
- __New(w,r,colourOut,colourIn,back,dr,str){
- this.r:=r,this.w:=w,this.colourOut:=colourOut,this.colourIn:=colourIn,this.g:=back.g,this.dr:=dr,this.str:=str,this.back:=back
- this.ArrowBlock:=[]
- }
- add(x,y,point,spot){
- this.ArrowBlock[spot]:=new BlockClass(x,y,this.w,this.r,this.colourOut,this.colourIn,this.back,this.dr,this.str,point)
- }
- draw(){
- for i , value in this.ArrowBlock {
- if(value.point > 0)
- value.draw()
- }
- }
- findSpot(){
- for i , value in this.ArrowBlock {
- if(value.point < 1)
- return i
- }
- return this.ArrowBlock.length() + 1
- }
- move(step){
- for i , value in this.ArrowBlock {
- value.y+=step
- }
- }
- }
- class Matrix {
- __New(quaX,quaY,Squa,BlockS){
- this.BlockS:=BlockS
- this.matrix:=[]
- this.Squa:=Squa, this.quaX:=quaX, this.quaY:=quaY , quaX+=2 , quaY+=2
- loop % quaY {
- y:=A_Index - 2
- matrix:=[]
- loop % quaY {
- x:=A_Index - 2
- matrix[x]:=0
- }
- this.matrix[y]:=matrix.clone()
- }
- }
- ranadd(){
- loop % this.quaX {
- Random,point,-48,16
- this.add(A_Index - 1,0,point)
- }
- }
- add(xpos,ypos,point){
- spot:=this.BlockS.findSpot()
- x:=xpos*this.Squa + this.back.x1 + this.back.d + this.Squa/2
- y:=ypos*this.Squa + this.back.y1 + this.back.d + this.Squa/2
- this.BlockS.add(x,y,point,spot)
- this.matrix[ypos][xpos]:=this.BlockS.ArrowBlock[spot]
- }
- setBack(X1,Y1,d,COLOURfront,COLOURback,popup){
- this.back:=new BackClass(X1,Y1,X1+2*d + this.quaX*this.Squa,Y1+2*d + this.quaY*this.Squa,d,COLOURfront,COLOURback,popup)
- }
- matrixMoveSmooth(cycle){
- this.BlockS.move(this.squa/cycle)
- }
- matrixMove(){
- quaY:=this.quaY - 1
- t:=quaY
- loop % quaY {
- matrix:=this.matrix[t-1].clone()
- this.matrix[t]:=matrix.clone()
- t--
- }
- for i, value in this.matrix[this.quaY-1] {
- if(value.point > 0 )
- gosub gameOver
- }
- return
- gameover:
- MsgBox,GAME OVER
- return
- }
- formBlocks( ball ){
- x:= (ball.x - (this.back.x1 + this.back.d) )//this.Squa
- y:= (ball.y - (this.back.y1 + this.back.d) )//this.Squa
- x:=Floor(x),y:=floor(y)
- ;~ Sleep 50
- blocks:=[]
- x--
- y--
- x0:=x
- y0:=y
- loop 3 {
- x:=x0
- loop 3 {
- if(this.matrix[y][x].point > 0)
- blocks.Insert(this.matrix[y][x])
- ;~ MsgBox
- x++
- }
- y++
- }
- ;~ if( blocks.length() <> 0 )
- ;~ MsgBox
- return blocks
- }
- moveBallz(tacts,ballz){
- for i,value in ballz
- value.vx/=tacts, value.vy/=tacts, value.g/=tacts
- loop % tacts {
- for i,value in ballz
- value.move()
- for i,value in ballz {
- blocks:=this.formBlocks(value)
- for j,block in blocks {
- tvx:=value.vx, tvy:=value.vy
- block.bump(value)
- if(tvx <> value.vx || tvy <> value.vy)
- block.point--
- }
- }
- for i,value in ballz
- value.bounce()
- }
- for i,value in ballz
- value.vx*=tacts, value.vy*=tacts, value.g*=tacts
- }
- }
- class BallClass {
- __New(X,Y,R,COLOUR,v,ANGLE,G,BACK){
- this.x:=x,this.y:=y,this.r:=r,this.colour:=colour,this.vx:=v*cosg(angle),this.vy:=v*sing(angle),this.angle:=angle,this.g:=g,this.back:=back
- }
- move(){
- if(this.vx = this.vy && this.vy = 0)
- return
- this.vy+=this.g, this.y+=this.vy, this.x+=this.vx
- }
- draw(){
- Fill_ellipse(this.back.g,this.colour,this.x - this.r,this.y - this.r,2*this.r,2*this.r)
- }
- bounce(){
- if(this.x <= this.back.x1 +this.back.d + this.r)
- this.x:=this.back.x1 +this.back.d + this.r + 1, this.vx:= - this.vx
- else if(this.x >= this.back.x2 - this.back.d - this.r)
- this.x:=this.back.x2 - this.back.d - this.r - 1, this.vx:= - this.vx
- if(this.y <= this.back.y1 +this.back.d + this.r)
- this.y:=this.back.y1 +this.back.d + this.r + 1, this.vy:= - this.vy
- else if(this.y >= this.back.y2 - this.back.d - this.r)
- this.y:=this.back.y2 - this.back.d - this.r -1 ,this.vy:=0, this.vx:=0
- }
- bump(ballDefender){
- ballAttacker:=this
- ball1:=ballAttacker, ball2:=ballDefender
- distMin:=ball1.r + ball2.r
- dist:=sqrt((ball2.x - ball1.x)**2 + (ball2.y - ball1.y)**2)
- if(dist <= distMin){
- v:=Sqrt(ball1.vx**2 + ball1.vy**2)
- angleCentre:=getAngle(ball2.x - ball1.x,ball2.y - ball1.y)
- angleSpeed:=getAngle(ball1.vx, ball1.vy)
- brandNewAngle:= 180 + 2*angleCentre - angleSpeed
- ball1.angle:=brandNewAngle
- ball1.vx:=v*cosg(brandNewAngle)
- ball1.vy:=v*sing(brandNewAngle)
- ball1.x:=ball2.x + (distMin + 1)*cosg(180 + angleCentre)
- ball1.y:=ball2.y + (distMin + 1)*sing(180 + angleCentre)
- }
- }
- }
- class Launch {
- __New(ballz,back){
- this.ballz:=ballz, this.back := back
- this.y0:=back.y2 - back.d
- this.Firsttouch:=0
- this.lastLaunched:=0
- this.lauchEnded := 1
- }
- touch(){
- if( this.Firsttouch <> 0)
- return
- for i,value in this.ballz.ArroWballz {
- if(i > this.lastLaunched)
- break
- if(value.vx = 0 && value.vy = 0){
- this.Firsttouch := i
- break
- }
- }
- }
- drawArrow(g){
- MouseGetPos,x,y
- x0:=this.ballz.ArroWballz[this.Firsttouch].x
- y0:=this.y0
- x2:=x0-x, y2:=-abs(y0-y)
- if(y0-y > 0 )
- x2:=-x2
- long:=Sqrt(x2**2+y2**2)
- longMIN:=150
- longMax:=450
- loop:=3
- longMIN/=loop
- longMax/=loop
- if(long < longMIN )
- x2:=x2*(longMIN/long), y2:=y2*(longMIN/long)
- else if (long > longMax)
- x2:=x2*(longMax/long), y2:=y2*(longMax/long)
- long:=Sqrt(x2**2+y2**2)
- dS:=5
- dR:=6
- loop % dS {
- x:=A_Index*loop*x2/ds + x0 - dr/2
- y:=A_Index*loop*y2/ds + y0 - dr/2
- fill_ellipse(g,"ffffff",x,y,dr,dr)
- }
- angle:=getangle(x2,y2)
- v:=long/9
- Vangle:={v:v,angle:angle}
- return Vangle.clone()
- }
- allToTouch(){
- for i,value in this.ballz.ArroWballz {
- if(i > this.lastLaunched)
- break
- if(value.vx = 0 && value.vy = 0){
- if(abs(value.x - this.ballz.ArroWballz[this.Firsttouch].x) <= 1)
- value.x:=this.ballz.ArroWballz[this.Firsttouch].x
- else {
- if(value.x > this.ballz.ArroWballz[this.Firsttouch].x)
- value.x--
- else
- value.x++
- }
- }
- }
- }
- iflaunch(){
- speed:=0
- for i , value in this.ballz.ArroWballz
- speed+=abs(value.vx) + abs(value.vy)
- if(speed = 0){
- return true
- }
- return false
- }
- launchEm(v,angle){
- if(this.lastLaunched = this.ballz.ArroWballz.length()){
- this.lauchEnded := 1
- return
- }
- if(this.lauchEnded = 1){
- this.lauchEnded := 0
- this.Firsttouch:=0
- this.lastLaunched:=0
- }
- else {
- this.lastLaunched++
- this.ballz.ArroWballz[this.lastLaunched].vx:=v*cosg(angle),this.ballz.ArroWballz[this.lastLaunched].vy:=v*sing(angle)
- this.ballz.ArroWballz[this.lastLaunched].angle:=angle
- }
- }
- }
- class ballz {
- __New(back,COLOUR,r,g){
- this.ArroWballz:=[]
- this.back:=back,this.colour:=colour,this.g:=g,this.r:=r
- }
- add(x,y,v,angle){
- this.ArroWballz.insert(new BallClass(X,Y,this.R,this.COLOUR,v,ANGLE,this.G,this.BACK))
- }
- move(){
- for i , value in this.ArroWballz
- value.move()
- }
- draw(){
- for i , value in this.ArroWballz
- value.draw()
- }
- bounce(){
- for i , value in this.ArroWballz
- value.bounce()
- }
- bump(ballDefender){
- for i , value in this.ArroWballz
- value.bump(ballDefender)
- }
- }
- class BackClass {
- __New(X1,Y1,X2,Y2,d,COLOURfront,COLOURback,popup){
- this.x1:=x1,this.x2:=x2,this.y1:=y1,this.y2:=y2,this.d:=d,this.colourfront:=colourfront,this.colourback:=colourback,this.g:=popup.g
- this.brush1:=new_brush("ff0000"),this.brush2:=new_brush("00f0f0")
- }
- draw(){
- w:=this.x2 - this.x1 + 1 - 2*this.d
- fill_boxX(this.g,this.colourfront,this.x1,this.y1,this.x2 - this.x1 + 1 , this.y2 - this.y1 + 1 + this.d*4)
- fill_boxX(this.g,this.colourback,this.x1 + this.d , this.y1 + this.d, this.x2 - this.x1 + 1 - 2*this.d , this.y2 - this.y1 + 1 - 2*this.d)
- ;~ Gdip_FillPie(this.g, this.brush1, this.x1 + this.d , this.y2 - w/2 - this.d , w, w, 0, 180)
- }
- }
- getAngle(dx,dy){
- r:=Sqrt(dx**2 + dy**2)
- if(dx>=0)
- angle:= asinG(dy/r)
- else if(dy>=0)
- angle:= acosG(dx/r)
- else if(dx < 0 && dy < 0)
- angle:= 180 + asing(abs(dy/r))
- while(angle < 0)
- angle+=360
- return angle
- }
- x::
- gosub getOutOfHere
- return
- getOutOfHere:
- ExitApp
- Layered_Window_ShutDown(popUp)
- return
- 1::
- SetTimer,gameLoop,0
- return
- 2::
- SetTimer,gameLoop,17
- return
- 3::
- SetTimer,gameLoop,170
- return
- 4::
- SetTimer,gameLoop,500
- return
- 5::
- SetTimer,gameLoop,1250
- return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement