def Build(self): # create background background = mw2_GameObject("background") self.AddObject(background) bg_back = mw2_Image("bg_back", "../__Resources/Pong/background.png") bg_back.mSize = mw2_Vector2(800, 600) bg_back.AttachTo(background) self.AddObject(bg_back) bg_left = mw2_Rect("bg_left") bg_left.mSize = mw2_Vector2(400, 600) bg_left.mColor = mw2_Vector4(255, 100, 0, 100) bg_left.AttachTo(background) bg_left.LocalPosition( mw2_Vector2(-200, 0) ) self.AddObject(bg_left) bg_right = mw2_Rect("bg_right") bg_right.mSize = mw2_Vector2(400, 600) bg_right.mColor = mw2_Vector4(80, 100, 255, 80) bg_right.AttachTo(background) bg_right.LocalPosition( mw2_Vector2(200, 0) ) self.AddObject(bg_right) bg_netting = mw2_Image("bg_netting", "../__Resources/Pong/tex_netting.png") bg_netting.mSize = mw2_Vector2(10, 600) bg_netting.AttachTo(background) self.AddObject(bg_netting) # create paddle 1 paddle1 = mw2_GameObject("paddle1") paddle1.WorldPosition( mw2_Vector2(-350, 0) ) self.AddObject(paddle1) p1_fill = mw2_Rect("p1_fill") p1_fill.mSize = mw2_Vector2(30, 100) p1_fill.mColor = mw2_Vector4(255, 150, 0, 100) p1_fill.mStyle = mw2_Rect.Style.FILL p1_fill.AttachTo(paddle1) p1_fill.LocalPosition( mw2_Vector2(0, 0) ) self.AddObject(p1_fill) p1_line = mw2_Rect("p1_line") p1_line.mSize = mw2_Vector2(30, 100) p1_line.mColor = mw2_Vector4(255, 200, 0, 255) p1_line.mStyle = mw2_Rect.Style.LINE p1_line.AttachTo(paddle1) p1_line.LocalPosition( mw2_Vector2(0, 0) ) self.AddObject(p1_line) # create paddle 2 paddle2 = mw2_GameObject("paddle2") paddle2.WorldPosition( mw2_Vector2(350, 0) ) self.AddObject(paddle2) p2_fill = mw2_Rect("p2_fill") p2_fill.mSize = mw2_Vector2(30, 100) p2_fill.mColor = mw2_Vector4(0, 120, 255, 100) p2_fill.mStyle = mw2_Rect.Style.FILL p2_fill.AttachTo(paddle2) p2_fill.LocalPosition( mw2_Vector2(0, 0) ) self.AddObject(p2_fill) p2_line = mw2_Rect("p2_line") p2_line.mSize = mw2_Vector2(30, 100) p2_line.mColor = mw2_Vector4(70, 170, 255, 255) p2_line.mStyle = mw2_Rect.Style.LINE p2_line.AttachTo(paddle2) p2_line.LocalPosition( mw2_Vector2(0, 0) ) self.AddObject(p2_line) # create ball ball = mw2_GameObject("ball") self.AddObject(ball) ball_fill = mw2_Circle("ball_fill") ball_fill.mRadius = 15 ball_fill.mColor = mw2_Vector4(0, 120, 255, 100) ball_fill.mStyle = mw2_Circle.Style.FILL ball_fill.AttachTo(ball) self.AddObject(ball_fill) ball_line = mw2_Circle("ball_line") ball_line.mRadius = 15 ball_line.mColor = mw2_Vector4(70, 170, 255, 255) ball_line.mStyle = mw2_Circle.Style.LINE ball_line.AttachTo(ball) self.AddObject(ball_line) # create score scoreText1 = mw2_Text( "scoreText1", "../__Resources/Pong/Ericsson-GA628.ttf", 80, "01", mw2_Vector4(210, 184, 137, 255), mw2_Text.Align.CENTER ) scoreText1.WorldPosition( mw2_Vector2(-150, -260) ) self.AddObject(scoreText1) scoreText2 = mw2_Text( "scoreText2", "../__Resources/Pong/Ericsson-GA628.ttf", 80, "02", mw2_Vector4(210, 184, 137, 255), mw2_Text.Align.CENTER ) scoreText2.WorldPosition( mw2_Vector2(150, -260) ) self.AddObject(scoreText2)
def Build(self): # background background = mw2_Image("background", "../__Resources/Example/background.png") background.mSize = mw2_Vector2(1000, 500) self.AddObject(background) # ball ball = mw2_Image("ball", "../__Resources/Example/ball.png") ball.mSize = mw2_Vector2(50, 50) ball.AttachTo(background) ball.LocalPosition( mw2_Vector2(0, 160) ) self.AddObject(ball) rect = mw2_Rect("rect") rect.mSize = mw2_Vector2(15, 15) rect.mColor = mw2_Vector4(255, 100, 0, 200) rect.AttachTo(ball) rect.LocalPosition( mw2_Vector2(0, -50) ) self.AddObject(rect) circle = mw2_Circle("circle") circle.mRadius = 5 circle.mColor = mw2_Vector4(0, 255, 255, 255) circle.mStyle = mw2_Circle.Style.LINE circle.AttachTo(self.mCamera) circle.LocalPosition( mw2_Vector2(0, 0) ) self.AddObject(circle) # text text_title = mw2_Text( "text_title", "../__Resources/Example/Sketch_Block.ttf", 25, "Example Project", mw2_Vector4(255, 255, 150, 255), mw2_Text.Align.CENTER ) text_title.AttachTo(self.mCamera) text_title.LocalPosition( mw2_Vector2(0, -200) ) self.AddObject(text_title) text_bottom1 = mw2_Text( "text_bottom1", "../__Resources/Example/Sketch_Block.ttf", 16, "Usage example for MorcoWrapper2D.", mw2_Vector4(255, 255, 150, 255), mw2_Text.Align.CENTER ) text_bottom1.AttachTo(self.mCamera) text_bottom1.LocalPosition( mw2_Vector2(0, 140) ) self.AddObject(text_bottom1) text_bottom2 = mw2_Text( "text_bottom2", "../__Resources/Example/Sketch_Block.ttf", 16, "More details on www.morco.ro", mw2_Vector4(255, 255, 150, 255), mw2_Text.Align.CENTER ) text_bottom2.AttachTo(self.mCamera) text_bottom2.LocalPosition( mw2_Vector2(0, 170) ) self.AddObject(text_bottom2) # controls controls = mw2_GameObject("controls") controls.WorldPosition( mw2_Vector2(-180, -30) ) self.AddObject(controls) text_controls = mw2_Text( "text_controls", "../__Resources/Example/BrushHandNew.ttf", 20, "Controls", mw2_Vector4(50, 255, 200, 255), mw2_Text.Align.LEFT ) text_controls.AttachTo(controls) text_controls.LocalPosition( mw2_Vector2(0, 0) ) self.AddObject(text_controls) text_wasd = mw2_Text( "text_wasd", "../__Resources/Example/BrushHandNew.ttf", 20, "W-A-S-D-Q-E", mw2_Vector4(50, 255, 200, 255), mw2_Text.Align.LEFT ) text_wasd.AttachTo(controls) text_wasd.LocalPosition( mw2_Vector2(0, 30) ) self.AddObject(text_wasd) text_arrows = mw2_Text( "text_arrows", "../__Resources/Example/BrushHandNew.ttf", 20, "left-right arrows", mw2_Vector4(50, 255, 200, 255), mw2_Text.Align.LEFT ) text_arrows.AttachTo(controls) text_arrows.LocalPosition( mw2_Vector2(0, 60) ) self.AddObject(text_arrows) text_space = mw2_Text( "text_space", "../__Resources/Example/BrushHandNew.ttf", 20, "space", mw2_Vector4(50, 255, 200, 255), mw2_Text.Align.LEFT ) text_space.AttachTo(controls) text_space.LocalPosition( mw2_Vector2(0, 90) ) self.AddObject(text_space) text_r = mw2_Text( "text_r", "../__Resources/Example/BrushHandNew.ttf", 20, "R", mw2_Vector4(50, 255, 200, 255), mw2_Text.Align.LEFT ) text_r.AttachTo(controls) text_r.LocalPosition( mw2_Vector2(0, 120) ) self.AddObject(text_r) text_rotate = mw2_Text( "text_rotate", "../__Resources/Example/Sketch_Block.ttf", 20, "LEFT", mw2_Vector4(255, 255, 200, 255), mw2_Text.Align.LEFT ) text_rotate.LocalPosition( mw2_Vector2(0, 0) ) self.AddObject(text_rotate)