def Build(self): # background background = mw2_Image("background", "../__Resources/Pong/background.png") background.mSize = mw2_Vector2(800, 600) self.AddObject(background) # top top = mw2_GameObject("top") top.WorldPosition( mw2_Vector2(0, -250) ) self.AddObject(top) text_gameOver = mw2_Text( "text_gameOver", "../__Resources/Pong/Ericsson-GA628.ttf", 50, "Game Over", mw2_Vector4(210, 184, 137, 255), mw2_Text.Align.CENTER ) text_gameOver.AttachTo(top) text_gameOver.LocalPosition( mw2_Vector2(0, 0) ) self.AddObject(text_gameOver) winner = mw2_Text( "winner", "../__Resources/Pong/Ericsson-GA628.ttf", 25, "...", mw2_Vector4(210, 184, 137, 255), mw2_Text.Align.CENTER ) winner.AttachTo(top) winner.LocalPosition( mw2_Vector2(0, 60) ) self.AddObject(winner) # middle 1 middle1 = mw2_GameObject("middle1") middle1.WorldPosition( mw2_Vector2(0, -120) ) self.AddObject(middle1) leftSide = mw2_GameObject("leftSide") leftSide.AttachTo(middle1) leftSide.LocalPosition( mw2_Vector2(-320, 0) ) self.AddObject(leftSide) rightSide = mw2_GameObject("rightSide") rightSide.AttachTo(middle1) rightSide.LocalPosition( mw2_Vector2(-100, 0) ) self.AddObject(rightSide) # left side text_title = mw2_Text( "text_title", "../__Resources/Pong/Ericsson-GA628.ttf", 32, "Credits", mw2_Vector4(210, 184, 137, 255), mw2_Text.Align.LEFT ) text_title.AttachTo(leftSide) text_title.LocalPosition( mw2_Vector2(0, 0) ) self.AddObject(text_title) text_item1 = mw2_Text( "text_item1", "../__Resources/Pong/Ericsson-GA628.ttf", 25, "Background", mw2_Vector4(210, 184, 137, 255), mw2_Text.Align.LEFT ) text_item1.AttachTo(leftSide) text_item1.LocalPosition( mw2_Vector2(0, 40) ) self.AddObject(text_item1) text_item2 = mw2_Text( "text_item2", "../__Resources/Pong/Ericsson-GA628.ttf", 25, "Sounds", mw2_Vector4(210, 184, 137, 255), mw2_Text.Align.LEFT ) text_item2.AttachTo(leftSide) text_item2.LocalPosition( mw2_Vector2(0, 65) ) self.AddObject(text_item2) text_item3 = mw2_Text( "text_item3", "../__Resources/Pong/Ericsson-GA628.ttf", 25, "Music", mw2_Vector4(210, 184, 137, 255), mw2_Text.Align.LEFT ) text_item3.AttachTo(leftSide) text_item3.LocalPosition( mw2_Vector2(0, 90) ) self.AddObject(text_item3) text_item4 = mw2_Text( "text_item4", "../__Resources/Pong/Ericsson-GA628.ttf", 25, "Icons", mw2_Vector4(210, 184, 137, 255), mw2_Text.Align.LEFT ) text_item4.AttachTo(leftSide) text_item4.LocalPosition( mw2_Vector2(0, 115) ) self.AddObject(text_item4) text_item5 = mw2_Text( "text_item5", "../__Resources/Pong/Ericsson-GA628.ttf", 25, "Font", mw2_Vector4(210, 184, 137, 255), mw2_Text.Align.LEFT ) text_item5.AttachTo(leftSide) text_item5.LocalPosition( mw2_Vector2(0, 140) ) self.AddObject(text_item5) # right side text_url1 = mw2_Text( "text_url1", "../__Resources/Pong/Ericsson-GA628.ttf", 25, "http://subtlepatterns.com", mw2_Vector4(210, 184, 137, 255), mw2_Text.Align.LEFT ) text_url1.AttachTo(rightSide) text_url1.LocalPosition( mw2_Vector2(0, 40) ) self.AddObject(text_url1) text_url2 = mw2_Text( "text_url2", "../__Resources/Pong/Ericsson-GA628.ttf", 25, "http://www.freesound.org", mw2_Vector4(210, 184, 137, 255), mw2_Text.Align.LEFT ) text_url2.AttachTo(rightSide) text_url2.LocalPosition( mw2_Vector2(0, 65) ) self.AddObject(text_url2) text_url3 = mw2_Text( "text_url3", "../__Resources/Pong/Ericsson-GA628.ttf", 25, "https://soundcloud.com", mw2_Vector4(210, 184, 137, 255), mw2_Text.Align.LEFT ) text_url3.AttachTo(rightSide) text_url3.LocalPosition( mw2_Vector2(0, 90) ) self.AddObject(text_url3) text_url4 = mw2_Text( "text_url4", "../__Resources/Pong/Ericsson-GA628.ttf", 25, "http:#findicons.com", mw2_Vector4(210, 184, 137, 255), mw2_Text.Align.LEFT ) text_url4.AttachTo(rightSide) text_url4.LocalPosition( mw2_Vector2(0, 115) ) self.AddObject(text_url4) text_url5 = mw2_Text( "text_url5", "../__Resources/Pong/Ericsson-GA628.ttf", 25, "http://www.dafont.com", mw2_Vector4(210, 184, 137, 255), mw2_Text.Align.LEFT ) text_url5.AttachTo(rightSide) text_url5.LocalPosition( mw2_Vector2(0, 140) ) self.AddObject(text_url5) # middle 2 middle2 = mw2_GameObject("middle2") middle2.WorldPosition( mw2_Vector2(-320, 60) ) self.AddObject(middle2) text_line1 = mw2_Text( "text_line1", "../__Resources/Pong/Ericsson-GA628.ttf", 25, "Game designed and developed by Morco.", mw2_Vector4(210, 184, 137, 255), mw2_Text.Align.LEFT ) text_line1.AttachTo(middle2) text_line1.LocalPosition( mw2_Vector2(0, 0) ) self.AddObject(text_line1) text_line2 = mw2_Text( "text_line2", "../__Resources/Pong/Ericsson-GA628.ttf", 25, "It is marked as open-source software.", mw2_Vector4(210, 184, 137, 255), mw2_Text.Align.LEFT ) text_line2.AttachTo(middle2) text_line2.LocalPosition( mw2_Vector2(0, 30) ) self.AddObject(text_line2) text_line3 = mw2_Text( "text_line3", "../__Resources/Pong/Ericsson-GA628.ttf", 25, "More details on www.morco.ro", mw2_Vector4(210, 184, 137, 255), mw2_Text.Align.LEFT ) text_line3.AttachTo(middle2) text_line3.LocalPosition( mw2_Vector2(0, 60) ) self.AddObject(text_line3) # bottom bottom = mw2_GameObject("bottom") bottom.WorldPosition( mw2_Vector2(330, 220) ) self.AddObject(bottom) text_restart = mw2_Text( "text_restart", "../__Resources/Pong/Ericsson-GA628.ttf", 20, "Press \"R\" to restart game.", mw2_Vector4(210, 184, 137, 255), mw2_Text.Align.RIGHT ) text_restart.AttachTo(bottom) text_restart.LocalPosition( mw2_Vector2(0, 0) ) self.AddObject(text_restart) text_exit = mw2_Text( "text_exit", "../__Resources/Pong/Ericsson-GA628.ttf", 20, "Press \"ESC\" to exit.", mw2_Vector4(210, 184, 137, 255), mw2_Text.Align.RIGHT ) text_exit.AttachTo(bottom) text_exit.LocalPosition( mw2_Vector2(0, 30) ) self.AddObject(text_exit)
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)
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/Pong/background.png") background.mSize = mw2_Vector2(800, 600) self.AddObject(background) # start start = mw2_GameObject("start") start.WorldPosition( mw2_Vector2(0, 180) ) self.AddObject(start) button_start = mw2_Rect("button_start") button_start.mSize = mw2_Vector2(80, 80) button_start.mColor = mw2_Vector4(255, 200, 30, 255) button_start.AttachTo(start) button_start.LocalPosition( mw2_Vector2(0, 0) ) self.AddObject(button_start) text_go = mw2_Text( "text_go", "../__Resources/Pong/Ericsson-GA628.ttf", 35, "GO", mw2_Vector4(1, 1, 1, 150), mw2_Text.Align.CENTER ) text_go.AttachTo(start) text_go.LocalPosition( mw2_Vector2(0, -15) ) self.AddObject(text_go) # game title text_gameTitle = mw2_Text( "text_gameTitle", "../__Resources/Pong/Ericsson-GA628.ttf", 60, "Pong Project", mw2_Vector4(210, 184, 137, 255), mw2_Text.Align.CENTER ) text_gameTitle.WorldPosition( mw2_Vector2(0, -250) ) self.AddObject(text_gameTitle) # controls controls = mw2_GameObject("controls") controls.WorldPosition( mw2_Vector2(-30, -120) ) self.AddObject(controls) text_controls = mw2_Text( "text_controls", "../__Resources/Pong/Ericsson-GA628.ttf", 40, "Controls", mw2_Vector4(210, 184, 137, 255), mw2_Text.Align.RIGHT ) text_controls.AttachTo(controls) text_controls.LocalPosition( mw2_Vector2(0, 0) ) self.AddObject(text_controls) text_line1 = mw2_Text( "text_line1", "../__Resources/Pong/Ericsson-GA628.ttf", 25, "W & S : Player 1", mw2_Vector4(210, 184, 137, 255), mw2_Text.Align.RIGHT ) text_line1.AttachTo(controls) text_line1.LocalPosition( mw2_Vector2(0, 50) ) self.AddObject(text_line1) text_line2 = mw2_Text( "text_line2", "../__Resources/Pong/Ericsson-GA628.ttf", 25, "Up & Down : Player 2", mw2_Vector4(210, 184, 137, 255), mw2_Text.Align.RIGHT ) text_line2.AttachTo(controls) text_line2.LocalPosition( mw2_Vector2(0, 80) ) self.AddObject(text_line2) text_line3 = mw2_Text( "text_line3", "../__Resources/Pong/Ericsson-GA628.ttf", 25, "ESC : Exit Game", mw2_Vector4(210, 184, 137, 255), mw2_Text.Align.RIGHT ) text_line3.AttachTo(controls) text_line3.LocalPosition( mw2_Vector2(0, 110) ) self.AddObject(text_line3) text_line4 = mw2_Text( "text_line4", "../__Resources/Pong/Ericsson-GA628.ttf", 25, "R : Restart Game", mw2_Vector4(210, 184, 137, 255), mw2_Text.Align.RIGHT ) text_line4.AttachTo(controls) text_line4.LocalPosition( mw2_Vector2(0, 140) ) self.AddObject(text_line4) # win condition winCondition = mw2_GameObject("winCondition") winCondition.WorldPosition( mw2_Vector2(180, 0) ) self.AddObject(winCondition) text_condition = mw2_Text( "text_condition", "../__Resources/Pong/Ericsson-GA628.ttf", 40, "WinCondition", mw2_Vector4(210, 184, 137, 255), mw2_Text.Align.CENTER ) text_condition.AttachTo(winCondition) text_condition.LocalPosition( mw2_Vector2(0, -120) ) self.AddObject(text_condition) winValue = mw2_Text( "winValue", "../__Resources/Pong/Ericsson-GA628.ttf", 50, "--", mw2_Vector4(210, 184, 137, 255), mw2_Text.Align.CENTER ) winValue.AttachTo(winCondition) winValue.LocalPosition( mw2_Vector2(0, -20) ) self.AddObject(winValue) button_plus = mw2_Image("button_plus", "../__Resources/Pong/icon_button-plus.png") button_plus.mSize = mw2_Vector2(50, 50) button_plus.AttachTo(winCondition) button_plus.LocalPosition( mw2_Vector2(100, 0) ) self.AddObject(button_plus) button_minus = mw2_Image("button_minus", "../__Resources/Pong/icon_button-minus.png") button_minus.mSize = mw2_Vector2(50, 50) button_minus.AttachTo(winCondition) button_minus.LocalPosition( mw2_Vector2(-100, 0) ) self.AddObject(button_minus)