Skip to content

Instantly share code, notes, and snippets.

View Mr-Coxall's full-sized avatar

Patrick Coxall Mr-Coxall

  • St. Mother Teresa HS
  • Ottawa
View GitHub Profile
-----------------------------------------------------------------------------------------
--
-- how to calculate the area of a square
--
-----------------------------------------------------------------------------------------
local lengthOfSquareTextField = native.newTextField( display.contentCenterX, display.contentCenterY + 200, 450, 75 )
lengthOfSquareTextField.id = "length textField"
local areaOfSquareTextField = display.newText( "Answer", display.contentCenterX, display.contentCenterY - 200, native.systemFont, 75 )
-----------------------------------------------------------------------------------------
--
-- how to add a text field and button, so that you can enter text
--
-----------------------------------------------------------------------------------------
local answerTextField = native.newTextField( display.contentCenterX, display.contentCenterY + 200, 450, 75 )
answerTextField.id = "answer textField"
local enterButton = display.newImageRect( "./assets/sprites/enterButton.png", 406, 157 )
-----------------------------------------------------------------------------------------
--
-- main.lua
--
-- Created by: Mr. Coxall
-- Created on: Jan 2018
--
-- This file prints "Hello, World!" to the console
-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------
--
-- how to add a background color and an image to your screen
--
-----------------------------------------------------------------------------------------
-- Set default screen background color to blue
display.setDefault( "background", 0, 0, 1 )
-- note that the image is saved in a directory ./assests/sprites/
-----------------------------------------------------------------------------------------
--
-- how to add text to the screen
--
-----------------------------------------------------------------------------------------
local myText = display.newText( "Hello World!", 100, 200, native.systemFont, 16 )
myText:setFillColor( 1, 0, 0 )
-----------------------------------------------------------------------------------------
--
-- how to add an event listener, so that when you touch an image you get feedback
--
-----------------------------------------------------------------------------------------
local soccerBall = display.newImageRect( "./assets/sprites/ball.png", 500, 480 )
soccerBall.x = display.contentCenterX
soccerBall.y = display.contentCenterY
soccerBall.id = "ball object"
@Mr-Coxall
Mr-Coxall / Git2Go_to_Pythonista.py
Created September 8, 2017 17:06
Git2Go_to_Pythonista.py
# Created by: omz
# Created on: Feb 2016
# base code from:
# https://gist.github.com/Mr-Coxall/4144acc87c6cc503b84c0e5dfe79fbcf
# Altered by: Mr. Coxall
# Created on: Nov 2016
# Used to write out a single file selected from the sharesheet and
# then write it out to your in your Pythonista directory that you select
@Mr-Coxall
Mr-Coxall / game_scene.py
Created January 13, 2017 14:46
game_scene.py
# Created by: Anna Devlin
# Created on: Dec 2016
# Created for: ICS3U
# This scene shows the main game
from scene import *
import ui
from numpy import random
@Mr-Coxall
Mr-Coxall / date_picker.py
Created November 29, 2016 03:29
date_picker.py
# from: https://forum.omz-software.com/topic/1239/extracting-the-date-from-the-ui-date-and-time-spinner/6
import ui
a_date = None
def date_picker_action(sender):
my_date = sender.date
print(my_date)
@Mr-Coxall
Mr-Coxall / Git2Go_to_Pythonista.py
Created November 24, 2016 19:09
Git2Go_to_Pythonista.py
# Created by: omz
# Created on: Feb 2016
# base code from:
# https://gist.github.com/Mr-Coxall/4144acc87c6cc503b84c0e5dfe79fbcf
# Altered by: Mr. Coxall
# Created on: Nov 2016
# Used to write out a single file selected from the sharesheet and
# then write it out to your in your Pythonista directory that you select