pip install PySFML
python
import sfml as sf
import sys
python
window.framerate_limit = 60
python
menu_rect = sf.RectangleShape(sf.Vector2(200, 400))
menu_rect.position = sf.Vector2(300, 100)
menu_rect.fill_color = sf.Color.WHITE
button_rect = sf.RectangleShape(sf.Vector2(150, 50))
button_rect.position = sf.Vector2(325, 150)
button_rect.fill_color = sf.Color(200, 200, 200)
button_text.character_size = 24
button_text.position = sf.Vector2(360, 165)
python
while window.is_open:
for event in window.events:
if type(event) is sf.CloseEvent:
window.close()
elif type(event) is sf.MouseButtonEvent:
if button_rect.global_bounds.contains(event.position):
python
window.clear(sf.Color.BLACK)
window.draw(menu_rect)
window.draw(button_rect)
window.draw(button_text)
window.display()
python
import sfml as sf
import sys
window.framerate_limit = 60
menu_rect = sf.RectangleShape(sf.Vector2(200, 400))
menu_rect.position = sf.Vector2(300, 100)
menu_rect.fill_color = sf.Color.WHITE
button_rect = sf.RectangleShape(sf.Vector2(150, 50))
button_rect.position = sf.Vector2(325, 150)
button_rect.fill_color = sf.Color(200, 200, 200)
button_text.character_size = 24
button_text.position = sf.Vector2(360, 165)
while window.is_open:
for event in window.events:
if type(event) is sf.CloseEvent:
window.close()
elif type(event) is sf.MouseButtonEvent:
if button_rect.global_bounds.contains(event.position):
window.clear(sf.Color.BLACK)
window.draw(menu_rect)
window.draw(button_rect)
window.draw(button_text)
window.display()