Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- { ;standart stuff that creates automaticly when you create new ahk script : CHANGED working dir to make access to sprites more easyly
- #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%\png ; easy way to find images
- }
- #SingleInstance,force
- SetBatchLines,-1
- #Include,<hellbents_gdip>
- popUp:=Layered_Window_SetUp(4,50,50,A_ScreenWidth,A_ScreenHeight,1,"+alwaysontop")
- UpdateLayeredWindow(popUp.hwnd, popUp.hdc, popUp.x, popUp.y, popUp.w, popUp.h)
- gosub setStuff
- SetTimer,gameLoop,% 1000/24
- return
- setStuff:
- backg:= new Back
- backg.set()
- alex:= new Ninja
- alex.set(250,250,100,200,"000ff0",10,25,50,backg)
- return
- gameLoop:
- Gdip_GraphicsClear(popUp.g)
- backg.draw(popup.g)
- alex.main(popup.g)
- UpdateLayeredWindow(popUp.hwnd, popUp.hdc)
- return
- class Ninja {
- set(x1,y1,w,h,colour,g,vxmax,vymax,Backscene){
- this.w:=w
- this.h:=h
- this.x1:=x1
- this.y1:=y1
- This.x2 := x1 + w
- This.y2 := y1 + h
- this.vx:=0
- this.vy:=0
- this.gmax:=g
- this.g:=0
- this.vxmax:=vxmax
- this.vymax:=vymax
- this.Backscene:=Backscene
- map := Gdip_CreateBitmap(w, h)
- g := Gdip_GraphicsFromImage(map)
- Gdip_SetSmoothingMode(g, 4)
- Fill_Boxx(g,colour,0,0,w,h)
- this.map:=map
- this.BW:=false
- this.BS:=false
- this.BA:=false
- this.BD:=false
- this.look:=1
- }
- readButtons(){
- this.BW:=false
- this.BS:=false
- this.BA:=false
- this.BD:=false
- if(GetKeyState("A"))
- this.BA:=true
- else if(GetKeyState("D"))
- this.BD:=true
- if(GetKeyState("S"))
- this.BS:=true
- else if (GetKeyState("W"))
- this.BW:=true
- }
- setlook(){
- if(this.vx > 0)
- this.look := 1
- else if(this.vx < 0)
- this.look := 2
- }
- main(g){
- this.readButtons()
- this.setv()
- this.setlook()
- this.setxy()
- this.smthUNDER()
- this.border()
- this.draw(g)
- this.vx:=0
- }
- smthUNDER(){
- this.g:=this.gmax
- if(this.y2 >= this.Backscene.y2){
- this.y2:=this.Backscene.y2
- this.y1:=this.y2 - this.h
- this.vy:=0
- this.g:=0
- this.BS:=false
- }
- }
- border(){
- if(this.x1 <= this.Backscene.x1){
- this.x1:=this.Backscene.x1
- this.x2:=this.x1 + this.w
- this.vx:=0
- this.BA:=false
- }
- else if(this.x2 >= this.Backscene.x2){
- this.x2:=this.Backscene.x2
- this.x1:=this.x2 - this.w
- this.vx:=0
- this.BD:=false
- }
- if(this.y1 <= this.Backscene.y1){
- this.y1:=this.Backscene.y1
- this.y2:=this.y1 + this.h
- this.vy:=0
- this.BW:=false
- }
- }
- setxy(){
- this.setx()
- this.sety()
- }
- setX(){
- this.x1+=this.vx
- this.x2:=this.x1 + this.w
- }
- sety(){
- this.y2+=this.vy
- this.y1:=this.y2 - this.h
- }
- setv(){
- this.setvx()
- this.setvy()
- }
- setVx(){
- vx:=this.vxmax
- if(this.BA){
- this.vx:=-vx
- this.BA:=false
- }
- else if(this.BD){
- this.vx:=vx
- this.BD:=false
- }
- }
- setVy(){
- this.vy+=this.g
- vy:=this.vymax
- vx:=this.vxmax
- if(this.vy <> 0){
- if(this.look = 1)
- this.vx:=vx
- else
- this.vx:=-vx
- }
- if(this.BW and this.vy = 0 and this.g = 0){
- this.vy:=-vy
- }
- if(this.BS and this.g <> 0){
- this.vy:=vy
- }
- }
- draw(g){
- Gdip_DrawImage(g, this.map, THIS.X1,this.y1, this.w, this.h)
- }
- }
- class Back {
- set(){
- back:=Gdip_CreateBitmapFromFile("back.png")
- this.back:=back
- Gdip_GetImageDimensions(back, w, h)
- this.w:=w
- this.h:=h
- delta:=14
- This.x1 := delta
- This.x2 := w - delta
- This.y1 := delta
- This.y2 := h - delta
- }
- draw(g){
- Gdip_DrawImage(g, this.back, 0,0, this.w, this.h)
- }
- }
- a::
- return
- s::
- return
- d::
- return
- w::
- return
- x::
- Layered_Window_ShutDown(popUp)
- ExitApp
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement