diff --git a/Debug/1heart.bmp b/Debug/1heart.bmp new file mode 100644 index 0000000..2df14a6 Binary files /dev/null and b/Debug/1heart.bmp differ diff --git a/Debug/2hearts.bmp b/Debug/2hearts.bmp new file mode 100644 index 0000000..d6f18fc Binary files /dev/null and b/Debug/2hearts.bmp differ diff --git a/Debug/3hearts.bmp b/Debug/3hearts.bmp new file mode 100644 index 0000000..8986c7b Binary files /dev/null and b/Debug/3hearts.bmp differ diff --git a/Debug/MarioProject.vcxproj b/Debug/MarioProject.vcxproj new file mode 100644 index 0000000..4c9964d --- /dev/null +++ b/Debug/MarioProject.vcxproj @@ -0,0 +1,132 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + + + + + + + 15.0 + {47256415-959D-4D2F-B533-065D91001A13} + MarioProject + 10.0.16299.0 + + + + Application + true + v141 + MultiByte + + + Application + false + v141 + true + MultiByte + + + Application + true + v141 + MultiByte + + + Application + false + v141 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + + + + Level3 + Disabled + true + true + + + Windows + + + + + Level3 + Disabled + true + true + + + + + Level3 + MaxSpeed + true + true + true + true + + + true + true + + + + + Level3 + MaxSpeed + true + true + true + true + + + true + true + + + + + + + \ No newline at end of file diff --git a/Debug/MarioProject.vcxproj.filters b/Debug/MarioProject.vcxproj.filters new file mode 100644 index 0000000..f5eb544 --- /dev/null +++ b/Debug/MarioProject.vcxproj.filters @@ -0,0 +1,30 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + + + Header Files + + + Header Files + + + \ No newline at end of file diff --git a/Debug/Mreka2.0.bmp b/Debug/Mreka2.0.bmp new file mode 100644 index 0000000..0fb831c Binary files /dev/null and b/Debug/Mreka2.0.bmp differ diff --git a/Debug/coin.bmp b/Debug/coin.bmp new file mode 100644 index 0000000..908cfc3 Binary files /dev/null and b/Debug/coin.bmp differ diff --git a/Debug/data.inc b/Debug/data.inc new file mode 100644 index 0000000..0784367 --- /dev/null +++ b/Debug/data.inc @@ -0,0 +1,140 @@ +.data + +vy dword 0 +time dword 0 +acl dword 1 + +scr0 byte "Score:0",0 +scrone byte "Score:1",0 +scrtwo byte "Score:2",0 +scrthree byte "Score:3",0 +scrfour byte "Score:4",0 +scrfive byte "Score:5",0 +scrsix byte "Score:6",0 + +score dword 0 +numH dword 3 +jumpUp dword 0 + +picture byte "mario.bmp",0 +pictureScnd byte "mario2.bmp",0 + +Dmoot STRUCT + info Img<> ;0-19 + pos POINT<0,380> ;20-27 + centerP POINT<24,54> ;28-35 + rad dword 28 ;36-39 + centerT POINT<> ;40-47 + draw dword 1 ;48-51 + + drc POINT<0,0> ;52-59 + borderx DWORD 800 + borderyU DWORD 200 + borderyD DWORD 476 + picNum dword 1 + +Dmoot ENDS + +mario Dmoot<> +mario2 Dmoot<> + + +rekka byte "Mreka2.0.bmp",0 + +Reka STRUCT + + info Img<> + xinpic dword 0 + winpic dword 800 + +Reka ENDS + +bckrnd Reka<> + + + +coin byte "coin.bmp",0 +coins STRUCT + info Img<> + pos POINT<400,260> + centerP POINT<18,18> + rad dword 20 + centerT POINT<> + draw dword 1 + + drc POINT<-1,0> +coins ENDS + +coin1 coins<> +coin2 coins<<>,<50,260>,<>,<>,<>,<>,<-3,0>> +coin3 coins<<>,<200,300>,<>,<>,<>,<>,<-5,0>> +coin4 coins<<>,<700,280>,<>,<>,<>,<>,<-4,0>> +coin5 coins<<>,<500,320>,<>,<>,<>,<>,<-2,0>> + + +enemyR byte "enemies.bmp",0 +enemyL byte "enemisL.bmp",0 + +enemys STRUCT + info Img<> + pos POINT<700,432> + centerP POINT<23,23> + rad dword 23 + centerT POINT<> + + drc POINT<-2,0> + picNum dword 2 + border dword 800 + bordery dword ? + +enemys ENDS + +enemy1 enemys<> +enemy2 enemys<> + +lose byte "youlost.bmp",0 +won byte "youwon.bmp",0 +opening byte "openingScreen.bmp",0 + +screenPic STRUCT + + info Img<> + pos POINT<150,150> + show dword 0 + +screenPic ENDS + +youLost screenPic<> +youwon screenPic<> +open screenPic<<>,<0,0>> + + +heart1 byte "1heart.bmp",0 +heart2 byte "2hearts.bmp",0 +heart3 byte "3hearts.bmp",0 + + +num0 byte "num0.bmp",0 +num1 byte "num1.bmp",0 +num2 byte "num2.bmp",0 +num3 byte "num3.bmp",0 +num4 byte "num4.bmp",0 +num5 byte "num5.bmp",0 + + +Count STRUCT + info Img<> + pos POINT<0,0> + +Count ENDS + +oneH Count<> +twoH Count<> +threeH Count<> + +nm0 Count<<>,<746,0>> +nm1 Count<<>,<746,0>> +nm2 Count<<>,<746,0>> +nm3 Count<<>,<746,0>> +nm4 Count<<>,<746,0>> +nm5 Count<<>,<746,0>> \ No newline at end of file diff --git a/Debug/drd.inc b/Debug/drd.inc new file mode 100644 index 0000000..b395ad0 --- /dev/null +++ b/Debug/drd.inc @@ -0,0 +1,132 @@ + +; initialize a window or full screen display +; width & height in pixels +; can be called multiple times to change view +drd_init PROTO STDCALL wdth:DWORD, heght:DWORD, flags:DWORD + +; - flags needs to be one of the following: +; normal window with a frame +INIT_WINDOW equ 0 +; sets the screen resolution and take over the screen +; notice: in this mode, you must redraw the entire screen in each frame from scratch (since there are two separate buffers) +INIT_FULLSCREEN equ 1 +; windown which covers the entive screen, don't take over the screen, width, height are ignored +INIT_WINDOWFULL equ 2 +; - and can have any of the following ored +; set the created window as top most and allow mouse events to fall through it to other applications +INIT_INPUT_FALLTHROUGH equ 4 +; add resizing option to the window border +; size of the drawing surface changes when window is resized. see drd_setResizeHandler to get the new size +INIT_RESIZABLE equ 8 +; same as above but the size of the drawing surface always remains the same and is stretched across the resized window +INIT_RESIZABLE_STRETCH equ 18h + +; used for drawing pixles using direct memory access +PixelPaint STRUCT + bufPtr DWORD ? ; address for the start of the buffer + pitch DWORD ? ; how much to add to bufPtr to get to the next scan line + bytesPerPixel DWORD ? ; number of bytes per pixel the draw surface has (depends on windows display settings, can be 2 or 4) + cheight DWORD ? + cwidth DWORD ? + wpitch DWORD ? +PixelPaint ENDS + +; lock the back surface for painting +; @param pp address to a PixelPaint instance +drd_pixelsBegin PROTO pp:DWORD + +; must be called at the end of painting the frame, before drd_flip() +drd_pixelsEnd PROTO + +; fill the back buffer in black +drd_pixelsClear PROTO color:DWORD + +; flip display and back buffers +drd_flip PROTO + +; setup a keyboard handler, called when a keyboard key is pressed down while in drd_processMessages +; func should be a pointer to a function which takes 1 DWORD which is the vkey code of the key +drd_setKeyHandler PROTO func:DWORD + +; setup a mouse message handler. +; func should be a pointer to a function which takes 3 DWORD: msg, wParam, lParam +drd_setMouseHandler PROTO func:DWORD + +; setup an error handler +; func should be a pointer to a function which takes 1 DWORD which is a pointer to a string describing the error +; if no handler is defined, an error messagebox appears +drd_setErrorHandler PROTO func:DWORD + +; setup a window resize handler. relevant only if INIT_RESIZABLE is passed to drd_init +; func should be a pointer to a function which takes 2 DWORDs, the new width and height of the resized window +; this function can be called before drd_init if you want the resize handler to be called when the window is created +drd_setResizeHandler PROTO func:DWORD + +; processes window messages from the user, return FALSE if Escape key was clicked +; this function should be called in a loop +drd_processMessages PROTO + +; set window to be translucent, alpha between 0 to 255 +drd_windowSetTranslucent PROTO alpha:BYTE + +; returns an HDC handle which can be used with GDI drawing functions. +drd_beginHdc PROTO + +; end GDI drawing on the hdc. a call to this function must be made with the value returned by drd_beginHdc +; otherwise drd_flip will fail +drd_endHdc PROTO hdc:DWORD + +; returns the handle (HWND) of the main window +drd_getMainHwnd PROTO + +; holds information about a loaded image +Img STRUCT + surface DWORD ? + iwidth DWORD ? + iheight DWORD ? + hasSrcKey DWORD ? + hbitmap DWORD ? +Img ENDS + +; load an image from file `filename` into an Img struct +drd_imageLoadFile PROTO filename:DWORD, pimg:DWORD + +; load an image from a resource compiled into the exe +drd_imageLoadResource PROTO id:DWORD, pimg:DWORD + + +; draw the image on the back buffer, starting at coord (dstX,dstY). must be outside drd_pixelsBegin +drd_imageDraw PROTO pimg:DWORD, dstX:DWORD, dstY:DWORD +; draw the image on the back buffer, take from the image the square [srcX, srcY, srcX+srcWidth, srcY+srcHeight] and put it at coord (dstX,dstY). must be outside drd_pixelsBegin +drd_imageDrawCrop PROTO pimg:DWORD, dstX:DWORD, dstY:DWORD, srcX:DWORD, srcY:DWORD, srcWidth:DWORD, srcHeight:DWORD + +; set the color which will be interpreted as transparency +drd_imageSetTransparent PROTO pimg:DWORD, color:DWORD + +; destroy the Img object +drd_imageDelete PROTO pimg:DWORD + +; each second, print the frame-per-second count +; append text to filename. if filename is NULL, the default file is c:/temp/drd_fps.txt +drd_printFps PROTO filename:DWORD + +; set the title of the main window to the given null-terminated string +drd_setWindowTitle PROTO strng:DWORD + + +; setup a handler to any window message +; msg is the WM_ message to register to, callback is a function the takes 3 DWORDs: message, wParam, lParam +; return value from the callback >= 0 is returned from the WinProc without further processing. returning -1 falls through the default drd message processing. +; This callback is useful for interception MM_MCINOTIFY sent by mciSendString "notify" flag +; warning: interception messages that are handled by drd may cause it not to function properly. see drd code for the messaged processed. +drd_setWinMsgHandler PROTO msg:DWORD, callback:DWORD + +; initialize an OpenGL context +drd_initGL PROTO + +; flip OpenGL's back and front buffers +drd_flipGL PROTO + +;------- crt replacement functions ----- +mrand PROTO +msrand PROTO seed:DWORD \ No newline at end of file diff --git a/Debug/drd.lib b/Debug/drd.lib new file mode 100644 index 0000000..193d65d Binary files /dev/null and b/Debug/drd.lib differ diff --git a/Debug/enemies.bmp b/Debug/enemies.bmp new file mode 100644 index 0000000..69247d3 Binary files /dev/null and b/Debug/enemies.bmp differ diff --git a/Debug/enemisL.bmp b/Debug/enemisL.bmp new file mode 100644 index 0000000..54ac0bc Binary files /dev/null and b/Debug/enemisL.bmp differ diff --git a/Debug/main.asm b/Debug/main.asm new file mode 100644 index 0000000..2af088a --- /dev/null +++ b/Debug/main.asm @@ -0,0 +1,94 @@ +include main_funcs.inc + +.code +main proc + invoke init + invoke borders + invoke transparent + + loopp: + invoke Sleep,20 + invoke update + invoke drd_pixelsClear,0 + invoke bckgrDraw + invoke openGame + + mov ebx,mario.draw + cmp ebx,0 + je drawLs + + mov ebx,score + cmp ebx,5 + jg drawWn + + mov ebx,0 + cmp open.show,ebx + je openingscreen + + invoke Mariodraw + + invoke control_keyboard + invoke move + invoke coinB, offset coin1 + invoke coinB, offset coin2 + invoke coinB, offset coin3 + invoke coinB, offset coin4 + invoke coinB, offset coin5 + + invoke coinMove, offset coin1 + invoke coinMove, offset coin2 + invoke coinMove, offset coin3 + invoke coinMove, offset coin4 + invoke coinMove, offset coin5 + invoke coinDraw + + invoke EMove + invoke Edraw + + invoke Mchangedrc + + invoke setPoints, offset mario + invoke setPoints, offset coin1 + invoke setPoints, offset coin2 + invoke setPoints, offset coin3 + invoke setPoints, offset coin4 + invoke setPoints, offset coin5 + invoke setPoints, offset enemy1 + + invoke collisionE, offset enemy1, offset mario + invoke collisionC, offset mario, offset coin1 + invoke collisionC, offset mario, offset coin2 + invoke collisionC, offset mario, offset coin3 + invoke collisionC, offset mario, offset coin4 + invoke collisionC, offset mario, offset coin5 + + invoke Hdraw + invoke Sdraw + + jmp loopp + + ret + + openingscreen: + invoke drd_imageDraw,offset open.info,open.pos.x,open.pos.y + jmp loopp + + drawLs: + invoke yLst + invoke GetAsyncKeyState,VK_SPACE + cmp eax,0 + jne RESTART + jmp loopp + + drawWn: + invoke yWon + invoke GetAsyncKeyState,VK_SPACE + cmp eax,0 + jne RESTART + jmp loopp + + RESTART: + invoke playAgain + jmp loopp +main endp +end main diff --git a/Debug/main_funcs.inc b/Debug/main_funcs.inc new file mode 100644 index 0000000..40df6ca --- /dev/null +++ b/Debug/main_funcs.inc @@ -0,0 +1,669 @@ +include \masm32\include\masm32rt.inc +include drd.inc +includelib drd.lib +include data.inc +.code + +init proc + invoke drd_init, 800,500,0 ;opens window, x=800, y=500 + invoke drd_imageLoadFile,offset rekka,offset bckrnd.info ;moves the file (image) from the hard disc to the ram and puts the information in the obj.info-Img stuct + invoke drd_imageLoadFile,offset opening,offset open.info + invoke drd_imageLoadFile,offset picture,offset mario.info + invoke drd_imageLoadFile,offset pictureScnd,offset mario2.info + invoke drd_imageLoadFile,offset coin,offset coin1.info + invoke drd_imageLoadFile,offset coin,offset coin2.info + invoke drd_imageLoadFile,offset coin,offset coin3.info + invoke drd_imageLoadFile,offset coin,offset coin4.info + invoke drd_imageLoadFile,offset coin,offset coin5.info + invoke drd_imageLoadFile,offset enemyR,offset enemy1.info + invoke drd_imageLoadFile,offset enemyL,offset enemy2.info + invoke drd_imageLoadFile,offset lose,offset youLost.info + invoke drd_imageLoadFile,offset heart1,offset oneH.info + invoke drd_imageLoadFile,offset heart2,offset twoH.info + invoke drd_imageLoadFile,offset heart3,offset threeH.info + invoke drd_imageLoadFile,offset num0,offset nm0.info + invoke drd_imageLoadFile,offset num1,offset nm1.info + invoke drd_imageLoadFile,offset num2,offset nm2.info + invoke drd_imageLoadFile,offset num3,offset nm3.info + invoke drd_imageLoadFile,offset num4,offset nm4.info + invoke drd_imageLoadFile,offset num5,offset nm5.info + invoke drd_imageLoadFile,offset won,offset youwon.info + + ret +init endp + +update proc + invoke drd_processMessages ;the window and it's buttons can be responsive + invoke drd_flip ;display objects from the buffer + ret +update endp + +bckgrDraw proc + pusha + + inc bckrnd.xinpic + dec bckrnd.winpic + mov ebx,bckrnd.info.iwidth + cmp bckrnd.xinpic,ebx + jge Tag_Reset + Ret_Reset: + + ;pimg:DWORD, dstX:DWORD, dstY:DWORD, srcX:DWORD, srcY:DWORD, srcWidth:DWORD, srcHeight:DWORD; + invoke drd_imageDrawCrop,offset bckrnd.info,0,0,bckrnd.xinpic,0,bckrnd.info.iwidth,bckrnd.info.iheight + invoke drd_imageDrawCrop,offset bckrnd.info,bckrnd.winpic,0,0,0,bckrnd.xinpic,bckrnd.info.iheight + popa + ret + + Tag_Reset: + mov bckrnd.xinpic,0 + mov ebx,bckrnd.info.iwidth + mov bckrnd.winpic,ebx + jmp Ret_Reset + popa + ret +bckgrDraw endp + +transparent proc + + invoke drd_imageSetTransparent ,offset mario, 0ffffffffh ;gets the offset of the image and the color in hexa and turns it to transparent + invoke drd_imageSetTransparent ,offset coin1, 0ffffffffh + invoke drd_imageSetTransparent ,offset coin2, 0ffffffffh + invoke drd_imageSetTransparent ,offset coin3, 0ffffffffh + invoke drd_imageSetTransparent ,offset coin4, 0ffffffffh + invoke drd_imageSetTransparent ,offset coin5, 0ffffffffh + invoke drd_imageSetTransparent ,offset mario2,0ffffffffh + invoke drd_imageSetTransparent ,offset enemy1, 0FFFF80h + invoke drd_imageSetTransparent ,offset enemy2, 0FFFF80h + invoke drd_imageSetTransparent ,offset youLost, 0000000h + invoke drd_imageSetTransparent ,offset youwon, 0000000h + invoke drd_imageSetTransparent ,offset youLost, 0ffffffffh + invoke drd_imageSetTransparent ,offset youwon, 0ffffffffh + invoke drd_imageSetTransparent ,offset open, 0ffffffffh + invoke drd_imageSetTransparent ,offset oneH, 0ffffffffh + invoke drd_imageSetTransparent ,offset twoH, 0ffffffffh + invoke drd_imageSetTransparent ,offset threeH, 0ffffffffh + invoke drd_imageSetTransparent ,offset nm0, 0ffffffffh + invoke drd_imageSetTransparent ,offset nm1, 0ffffffffh + invoke drd_imageSetTransparent ,offset nm2, 0ffffffffh + invoke drd_imageSetTransparent ,offset nm3, 0ffffffffh + invoke drd_imageSetTransparent ,offset nm4, 0ffffffffh + invoke drd_imageSetTransparent ,offset nm5, 0ffffffffh + +transparent endp + +openGame proc ;opens the game and sees if the player pressed the enter key in order to start the game + pusha + invoke GetAsyncKeyState,VK_RETURN + cmp eax,0 + jne SHOW + + popa + ret + + SHOW: + mov ebx,1 + mov open.show,ebx + popa + ret +openGame endp + +playAgain proc ;if the player loses or wins so it resets all the values to their original value + pusha + mov eax,380 + mov mario.pos.y,eax + + mov eax,0 + mov mario.pos.x,eax + mov mario.picNum,eax + mov mario.drc.x,eax + mov mario.drc.y,eax + mov score,eax + + mov eax,1 + mov mario.draw,eax + mov coin1.draw,eax + mov coin2.draw,eax + mov coin3.draw,eax + mov coin4.draw,eax + mov coin5.draw,eax + + mov eax,3 + mov numH,eax + + mov eax,700 + mov enemy1.pos.x,eax + popa + ret +playAgain endp + +Mariodraw proc + pusha + + mov ecx,mario.draw + cmp ecx,0 ;if you can draw mario + je returning + mov eax,mario.picNum ;if can, so which one of the two + cmp eax,1 + je firstPic + cmp eax,2 + je scndPic + + returning: + popa + ret + + firstPic: + invoke drd_imageDraw,offset mario.info,mario.pos.x,mario.pos.y ;draws the one facing right + + jmp returning + + scndPic: + invoke drd_imageDraw,offset mario2.info,mario.pos.x,mario.pos.y ;daws the one facing left + + jmp returning +Mariodraw endp + +coinMove proc objctAdr1:DWORD ;adds to each coin its speed and direction + pusha + + mov eax,objctAdr1 + mov ebx,[eax+52] + add [eax+20],ebx + + popa + ret +coinMove endp + +coinB proc adrObj:dword + pusha + + mov eax,adrObj + mov ebx,[eax+20] ;gets the pos.x of the coin + cmp ebx,-40 + jle chngX ;if it's less then -40 so... + popa + ret + + chngX: + mov ebx,950 + mov [eax+20],ebx ;moving 950 to pos.x + mov ecx,1 ;now able to draw the coin + mov [eax+48],ecx + popa + ret + +coinB endp + +coinDraw proc ;sees if can draw each coin + pusha + + mov eax,coin1.draw + cmp eax,0 ;if coin.draw=0, it can't draw the coin and it jumps to the next one + je scnd + invoke drd_imageDraw,offset coin1.info,coin1.pos.x,coin1.pos.y + + scnd: + mov eax,coin2.draw + cmp eax,0 + je thrd + invoke drd_imageDraw,offset coin2.info,coin2.pos.x,coin2.pos.y + + thrd: + mov eax,coin3.draw + cmp eax,0 + je forth + invoke drd_imageDraw,offset coin3.info,coin3.pos.x,coin3.pos.y + + forth: + mov eax,coin4.draw + cmp eax,0 + je fifth + invoke drd_imageDraw,offset coin4.info,coin4.pos.x,coin4.pos.y + + fifth: + mov eax,coin5.draw + cmp eax,0 + je returning + invoke drd_imageDraw,offset coin5.info,coin5.pos.x,coin5.pos.y + + returning: + popa + ret +coinDraw endp + +move proc + pusha + + mov ebx,mario.drc.y + mov ecx,jumpUp ;sees if mario can jump + cmp ecx,1 + je GO_UP + + popa + ret + + GO_UP: + add ebx,2 ;adds to the drc.y +2 + mov mario.drc.y,ebx + popa + ret + +move endp + +borders proc ;sets the border of mario and enemy1 + pusha + + mov eax,mario.borderx + sub eax,mario.info.iwidth + mov mario.borderx,eax ;x border based on image width + + mov eax,mario.borderyD + sub eax,mario.info.iheight + mov mario.borderyD,eax ;y border according to image height + + mov eax,enemy1.border + sub eax,enemy1.info.iwidth + mov enemy1.border,eax ;enemy x border based on image width + + popa + ret +borders endp + +Mchangedrc proc + pusha + + mov ebx,mario.drc.x + mov ecx,mario.drc.y + add mario.pos.x,ebx ;adds the speed in x to the x position + mov eax,mario.borderx + cmp mario.pos.x,eax ;sees if the pos.x equal or greater than the right x border + jge TAG_SWITCHX1 + cmp mario.pos.x,0 ;sees if the pos.x less or equal to 0 + jle TAG_SWITCHX2 + + add mario.pos.y,ecx ;adds the y speed to pos.y + mov eax,mario.borderyU + cmp mario.pos.y,eax ;sees if pos.y less or equal to the upper y border + jle TAG_SWITCHYD + mov eax,mario.borderyD + cmp mario.pos.y,eax ;sees if pos.y greater or equal to the down y border + jge TAG_STAYy + jmp RET_SWITCH + + RET_SWITCH: + popa + ret + + TAG_SWITCHX1: + mov ebx,mario.drc.x + imul ebx,-1 ;switches the direction of the speed + mov mario.drc.x,ebx + mov ebx,2 ; switches the number of picture + mov mario.picNum,ebx + mov ebx,mario.borderx ;sets the x position to start + mov mario.pos.x,ebx + jmp RET_SWITCH + + TAG_SWITCHX2: + mov ebx,mario.drc.x + imul ebx,-1 ;switches the direction of the speed + mov mario.drc.x,ebx + mov ebx,1 ; switches the number of picture + mov mario.picNum,ebx + mov ebx,0 ;sets the x position to start + mov mario.pos.x,ebx + jmp RET_SWITCH + + TAG_SWITCHYD: + mov ebx,mario.drc.y + imul ebx,-1 ;changes the direction of y + mov mario.drc.y,ebx + jmp RET_SWITCH + + TAG_STAYy: + mov ebx,0 ;sets the drc.y to 0 + mov mario.drc.y,ebx + jmp RET_SWITCH + +Mchangedrc endp + +Edraw proc + + mov eax,enemy1.picNum + cmp eax,1 + je firstPic ;if picNum=1 + cmp eax,2 + je scndPic ;if picNum=2 + returning: + ret + + firstPic: + invoke drd_imageDraw,offset enemy1.info,enemy1.pos.x,enemy1.pos.y + + jmp returning + + scndPic: + invoke drd_imageDraw,offset enemy2.info,enemy1.pos.x,enemy1.pos.y + + +Edraw endp + +EMove proc + pusha + + mov eax,enemy1.drc.x + add enemy1.pos.x,eax + mov ebx,enemy1.border + cmp enemy1.pos.x,ebx ;if pos.x greater or equal to the right x border + jge cngL + cmp enemy1.pos.x,0 ;if pos.x greater or equal to the 0 -x border + jle cngR + mov ecx,mario.pos.x + cmp enemy1.pos.x,ecx ;if enemy1.pos.x is less than mario.pos.x + jl mroR + jmp mroL +popa +ret + + cngL: + mov eax,enemy1.drc.x + imul eax,-1 ;switches the direction of the speed + mov enemy1.drc.x,eax + mov ecx,2 ; switches the number of picture + mov enemy1.picNum,ecx + popa + ret + + cngR: + mov eax,enemy1.drc.x + imul eax,-1 ;switches the direction of the speed + mov enemy1.drc.x,eax + mov ecx,1 ; switches the number of picture + mov enemy1.picNum,ecx + + popa + ret + + mroR: + mov edx,enemy1.drc.x + cmp edx,0 ;if the drc.x is less than 0 + jl cngR + + popa + ret + + mroL: + mov edx,enemy1.drc.x + cmp edx,0 ;if the drc.x is more than 0 + jg cngL + + popa + ret + +EMove endp + +yLst proc + pusha + + mov eax,numH + cmp eax,0 ;if the player lost all his life (3 hearts) + je draw + + popa + ret + + draw: + invoke drd_imageDraw,offset youLost.info,youLost.pos.x,youLost.pos.y ;shows the losing image + popa + ret +yLst endp + +yWon proc + pusha + + mov eax,score + cmp eax,5 ;if the player collected 5 coins + jle cnt + mov ebx,950 ;moves all the images to pos.x outside the window + mov mario.pos.x,ebx + mov coin1.pos.x,ebx + mov coin2.pos.x,ebx + mov coin3.pos.x,ebx + mov coin4.pos.x,ebx + mov coin5.pos.x,ebx + mov enemy1.pos.x,ebx + mov enemy2.pos.x,ebx + invoke drd_setWindowTitle, offset scrsix ;writes on the window title scrsix + invoke drd_imageDraw,offset youwon.info,youwon.pos.x,youwon.pos.y ;shows the winning image + cnt: + popa + ret + +yWon endp + +Hdraw proc + pusha + + mov eax,numH + cmp eax,3 + jne two + invoke drd_imageDraw,offset threeH.info,threeH.pos.x,threeH.pos.y ;if there are 3 hearts (numH) + mov ebx,1 + mov mario.draw,ebx ;allows to show mario again + popa + ret + + two: + cmp eax,2 + jne one + invoke drd_imageDraw,offset twoH.info,twoH.pos.x,twoH.pos.y ;if there are 2 hearts (numH) + mov ebx,1 + mov mario.draw,ebx ;allows to show mario again + popa + ret + + one: + cmp eax,1 + jne dntDraw + invoke drd_imageDraw,offset oneH.info,oneH.pos.x,oneH.pos.y ;if there are 1 hearts (numH) + mov ebx,1 + mov mario.draw,ebx ;allows to show mario again + popa + ret + + dntDraw: + popa + ret + +Hdraw endp + +Sdraw proc + pusha + + mov eax,score + cmp eax,0 + jne one + invoke drd_imageDraw,offset nm0.info,nm0.pos.x,nm0.pos.y ;if the score equals to 0 + invoke drd_setWindowTitle, offset scr0 ;writes on the window title scr0 + jmp cont + one: + cmp eax,1 + jne two + invoke drd_imageDraw,offset nm1.info,nm1.pos.x,nm1.pos.y ;if the score equals to 1 + invoke drd_setWindowTitle, offset scrone ;writes on the window title scrone + jmp cont + + two: + cmp eax,2 + jne three + invoke drd_imageDraw,offset nm2.info,nm2.pos.x,nm2.pos.y ;if the score equals to 2 + invoke drd_setWindowTitle, offset scrtwo ;writes on the window title scrtwo + jmp cont + + three: + cmp eax,3 + jne four + invoke drd_imageDraw,offset nm3.info,nm3.pos.x,nm3.pos.y ;if the score equals to 3 + invoke drd_setWindowTitle, offset scrthree ;writes on the window title scrthree + jmp cont + + four: + cmp eax,4 + jne five + invoke drd_imageDraw,offset nm4.info,nm4.pos.x,nm4.pos.y ;if the score equals to 4 + invoke drd_setWindowTitle, offset scrfour ;writes on the window title scrfour + jmp cont + + five: + cmp eax,5 + jne cont + invoke drd_imageDraw,offset nm5.info,nm5.pos.x,nm5.pos.y ;if the score equals to 5 + invoke drd_setWindowTitle, offset scrfive ;writes on the window title scrfive + jmp cont + + cont: + popa + ret + +Sdraw endp + +control_keyboard proc + pusha + + invoke GetAsyncKeyState,VK_LEFT + cmp eax,0 + jne TAG_GO_LEFT ;if the left key has been pressed + RET_GO_LEFT: + + invoke GetAsyncKeyState,VK_RIGHT + cmp eax,0 + jne TAG_GO_RIGHT ;if the right key has been pressed + RET_GO_RIGHT: + + invoke GetAsyncKeyState,VK_UP + cmp eax,0 + jne TAG_GO_UP ;if the upper key has been pressed + RET_GO_UP: + + popa + ret + + TAG_GO_LEFT: + mov mario.drc.x,-5 ;changes the mario.drc.x to -5 + mov ebx,2 + mov mario.picNum,ebx ;sets the picNum to 2 + jmp RET_GO_LEFT + + TAG_GO_RIGHT: + mov mario.drc.x,5 ;changes the mario.drc.x to 5 + mov ebx,1 + mov mario.picNum,ebx ;sets the picNum to 1 + jmp RET_GO_RIGHT + + TAG_GO_UP: + mov eax,mario.pos.y + cmp mario.borderyD,eax ;sees if mario still on the ground + jge NOTUP + mov mario.drc.y,-8 ;changes the mario.pos.y to 08 + mov jumpUp,1 + RETR: + mov eax, mario.drc.x + cmp eax,0 + jne KEEP + mov mario.drc.x,5 ;changes the mario.drc.x to 5 + KEEP: + + popa + ret + + NOTUP: + mov jumpUp,0 + popa + ret + +control_keyboard endp + +setPoints proc objctAdr1:DWORD + pusha + + mov eax,objctAdr1 + mov ebx,[eax+20] ;pos.x + add ebx,[eax+28] ;centerP.x + mov ecx,[eax+24] ;pos.y + add ecx,[eax+32] ;centerP.y + mov [eax+40],ebx ;centerT.x + mov [eax+44],ecx ;centerT.y +popa +ret +setPoints endp + +collisionC proc objctAdr1:DWORD, objctAdr2:DWORD ;the second might be erased during the game + pusha + + mov eax,objctAdr1 + mov ebx,objctAdr2 + mov ecx,[eax+40] ;x1 + sub ecx,[ebx+40] ;x1-x2 + mov edx,[eax+44] ;y1 + sub edx,[ebx+44] ;y1-y2 + imul ecx,ecx ;dx*dx + imul edx,edx ;dy*dy + add ecx,edx ;dx^2+dy^2 + mov eax,[eax+36] ;R1 + add eax,[ebx+36] ;R1+R2 + imul eax,eax ;Rt*Rt + cmp ecx,eax + jl DontDraw + + popa + ret + + DontDraw: + mov eax,950 + mov [ebx+20],eax ;moves the coin to pos.x outside the window + mov eax,score + inc eax + mov score,eax ;adds +1 to the score + popa + ret + +collisionC endp + +collisionE proc objctAdr1:DWORD, objctAdr2:DWORD ;the second might be erased during the game + pusha + + mov eax,objctAdr1 + mov ebx,objctAdr2 + mov ecx,[eax+40] ;x1 + sub ecx,[ebx+40] ;x1-x2 + mov edx,[eax+44] ;y1 + sub edx,[ebx+44] ;y1-y2 + imul ecx,ecx ;dx*dx + imul edx,edx ;dy*dy + add ecx,edx ;dx^2+dy^2 + mov eax,[eax+36] ;R1 + add eax,[ebx+36] ;R1+R2 + imul eax,eax ;Rt*Rt + cmp ecx,eax + jl DontDraw + + popa + ret + + DontDraw: + xor eax,eax + mov [ebx+48],eax ;dont draw mario + mov eax,numH + dec eax + mov numH,eax ;sub -1 from hearts (numH) + mov ebx,0 + mov mario.pos.x,ebx ;moves 0 to mario.pos.x + mov mario.drc.y,ebx ;moves 0 to mario.drc.y + mov mario.drc.x,ebx ;moves 0 to mario.drc.x + mov ebx,380 + mov mario.pos.y,ebx ;moves 380 to mario.pos.y + + popa + ret + +collisionE endp \ No newline at end of file diff --git a/Debug/mario.bmp b/Debug/mario.bmp new file mode 100644 index 0000000..650a658 Binary files /dev/null and b/Debug/mario.bmp differ diff --git a/Debug/mario2.bmp b/Debug/mario2.bmp new file mode 100644 index 0000000..3c11c42 Binary files /dev/null and b/Debug/mario2.bmp differ diff --git a/Debug/num0.bmp b/Debug/num0.bmp new file mode 100644 index 0000000..3b68513 Binary files /dev/null and b/Debug/num0.bmp differ diff --git a/Debug/num1.bmp b/Debug/num1.bmp new file mode 100644 index 0000000..262358b Binary files /dev/null and b/Debug/num1.bmp differ diff --git a/Debug/num2.bmp b/Debug/num2.bmp new file mode 100644 index 0000000..acd945b Binary files /dev/null and b/Debug/num2.bmp differ diff --git a/Debug/num3.bmp b/Debug/num3.bmp new file mode 100644 index 0000000..3ded3aa Binary files /dev/null and b/Debug/num3.bmp differ diff --git a/Debug/num4.bmp b/Debug/num4.bmp new file mode 100644 index 0000000..7ed763b Binary files /dev/null and b/Debug/num4.bmp differ diff --git a/Debug/num5.bmp b/Debug/num5.bmp new file mode 100644 index 0000000..2ed8728 Binary files /dev/null and b/Debug/num5.bmp differ diff --git a/Debug/openingScreen.bmp b/Debug/openingScreen.bmp new file mode 100644 index 0000000..624d1a4 Binary files /dev/null and b/Debug/openingScreen.bmp differ diff --git a/Debug/reka.bmp b/Debug/reka.bmp new file mode 100644 index 0000000..011a948 Binary files /dev/null and b/Debug/reka.bmp differ diff --git a/Debug/reka2.bmp b/Debug/reka2.bmp new file mode 100644 index 0000000..833b413 Binary files /dev/null and b/Debug/reka2.bmp differ diff --git a/Debug/star1.bmp b/Debug/star1.bmp new file mode 100644 index 0000000..cc8ae06 Binary files /dev/null and b/Debug/star1.bmp differ diff --git a/Debug/youlost.bmp b/Debug/youlost.bmp new file mode 100644 index 0000000..dfdd0a6 Binary files /dev/null and b/Debug/youlost.bmp differ diff --git a/Debug/youwon.bmp b/Debug/youwon.bmp new file mode 100644 index 0000000..2573eed Binary files /dev/null and b/Debug/youwon.bmp differ