Strict
Import mojo
Interface IUpdateable
Method OnUpdate:Int()
End
Interface IRenderable
Method OnRender:Int()
End
Class AbstractEntity Abstract
Global cw:Int
Global ch:Int
Method New (cw:Int, ch:Int)
Self.cw = cw;
Self.ch = ch;
End
End
Class Ball Extends AbstractEntity Implements IUpdateable, IRenderable
Field x:Int
Field y:Int
Field xs:Int
Field ys:Int
Method New ()
Self.x = 0
Self.y = 0
Self.xs = 1
Self.ys = 1
End
Method New (cw:Int, ch:Int)
Super.New(cw, ch)
Self.x = 0
Self.y = 0
Self.xs = 1
Self.ys = 1
End
Method OnUpdate:Int()
Self.x += xs
Self.y += ys
If Self.x > Self.cw-16 Or Self.x < 0
Self.xs =- Self.xs
End
If Self.y > Self.ch-16 Or Self.y < 0
Self.ys =- Self.ys
End
Return 0
End
Method OnRender:Int()
DrawCircle Self.x, Self.y, 16
Return 0
End
End
Class Pad Extends AbstractEntity Implements IUpdateable, IRenderable
Field x:Int
Field y:Int
Field xs:Int
Method New ()
Self.x = 0
Self.y = ch - 16
Self.xs = 1
End
Method New (cw:Int, ch:Int)
Super.New(cw, ch)
Self.x = 0
Self.y = ch - 16
Self.xs = 1
End
Method OnUpdate:Int()
Self.x += xs
If Self.x > Self.cw-64 Or Self.x < 0
Self.xs =- Self.xs
End
Return 0
End
Method OnRender:Int()
DrawRect Self.x, Self.y, 64, 8
Return 0
End
End
Class game Extends App
Field ball:Ball
Field pad:Pad
Method OnCreate:Int()
SetUpdateRate(60)
ball = New Ball(DeviceWidth(), DeviceHeight())
pad = New Pad()
Return 0
End
Method OnUpdate:Int()
ball.OnUpdate()
pad.OnUpdate()
Return 0
End
Method OnRender:Int()
Cls 0,0,0
ball.OnRender()
pad.OnRender()
Return 0
End
End
Function Main:Int()
New game
Return 0
End
This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.