Skip to content

Commit

Permalink
Add code highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
LeNPaul committed Jul 31, 2016
1 parent a29032c commit 72f6545
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 366 deletions.
15 changes: 15 additions & 0 deletions 404.html
@@ -0,0 +1,15 @@
---
layout: default
title: "404: Page not found"
permalink: 404.html
---

<div class="page">
<h1 class="page-title">404: Page not found</h1>

<iframe width="560" height="315" src="https://www.youtube.com/embed/SIaFtAKnqBU?autoplay=1&start=3" frameborder="0" allowfullscreen></iframe>

<h1>Ahhhhh!</h1>

<p class="lead">Sorry, we've misplaced that URL or it's pointing to something that doesn't exist. <a href="{{ site.baseurl }}/">Head back home</a> to try finding it again, or search for if on the <a href="{{ site.baseurl }}/writing.html">archives page</a>.</p>
</div>
304 changes: 4 additions & 300 deletions _posts/2016-07-17-code-test.md
Expand Up @@ -7,7 +7,7 @@ tags: [programming]

You can find the full list of supported programming languages <a href="https://github.com/jneen/rouge/wiki/List-of-supported-languages-and-lexers">here</a>

{% highlight js %}
{% highlight js linenos %}
// Example can be run directly in your JavaScript console

// Create a function that takes two arguments and returns the sum of those arguments
Expand All @@ -18,7 +18,9 @@ adder(2, 6);
// > 8
{% endhighlight %}

{% highlight py %}
<script src="https://gist.github.com/LeNPaul/8e0edee90081ecdb167a5e7b466d4b6a.js"></script>

{% highlight py linenos %}

import pygame
import simulator
Expand Down Expand Up @@ -105,302 +107,4 @@ def resetSimulation():
pygame.display.update()
clock.tick(15)

#Pause function

def pause(count):
paused = True

pygame.display.update()

while paused:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
quit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE:
paused = False
if event.key == pygame.K_r:
resetSimulation()
count = 0
if event.key == pygame.K_q:
pygame.quit()
quit()
if event.key in functionKeys:
functionKeys[event.key](simulationScreen)

simulationDisplay.fill(constant.black)
daysPassed(count)

messageFunction("Press space bar to continue simulation",parameter.displayWidth/2,parameter.displayHeight/2)

for particle in simulator.particleList:
x = int(simulationScreen.mx + (simulationScreen.dx + particle.px) * simulationScreen.magnification)
y = int(simulationScreen.my + (simulationScreen.dy + particle.py) * simulationScreen.magnification)

size = int(simulationScreen.magnification)

if size < 2:
pygame.draw.circle(simulationDisplay,constant.white,(x,y),1,1)
else:
pygame.draw.circle(simulationDisplay,constant.white,(x,y),size,0)

pygame.display.update()
clock.tick(5)

#Message to screen function

def textObjects(text, font):
textSurface = font.render(text, True, constant.white)
return textSurface, textSurface.get_rect()

def messageFunction(text,x,y):
largeText = pygame.font.Font('freesansbold.ttf',30)
textSurf, textRect = textObjects(text, largeText)
textRect.center = ((x), (y))
simulationDisplay.blit(textSurf, textRect)
#pygame.display.update()

#Button function

def button(text,x,y,buttonWidth,buttonHeight,inactiveColor,activeColor,action=None):

mouse = pygame.mouse.get_pos()
click = pygame.mouse.get_pressed()

if x + buttonWidth/2 > mouse[0] > x - buttonWidth/2 and y + buttonHeight/2 > mouse[1] > y - buttonHeight/2:
pygame.draw.rect(simulationDisplay, activeColor,(x-(buttonWidth/2),y-(buttonHeight/2),buttonWidth,buttonHeight))
if click[0] == 1 and action != None:
action()
else:
pygame.draw.rect(simulationDisplay, inactiveColor,(x-(buttonWidth/2),y-(buttonHeight/2),buttonWidth,buttonHeight))

smallText = pygame.font.Font("freesansbold.ttf",20)
textSurf, textRect = textObjects(text, smallText)
textRect.center = ( (x), (y))
simulationDisplay.blit(textSurf, textRect)

#Simulation start screen

def simulationIntro():

intro = True

while intro:

for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
quit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE:
intro = False
if event.key == pygame.K_r:
resetSimulation()
if event.key == pygame.K_q:
pygame.quit()
quit()
if event.key in functionKeys:
functionKeys[event.key](simulationScreen)

simulationDisplay.fill(constant.black)

#Draw initial particles
for particle in simulator.particleList:

x = int(simulationScreen.mx + (simulationScreen.dx + particle.px) * simulationScreen.magnification)
y = int(simulationScreen.my + (simulationScreen.dy + particle.py) * simulationScreen.magnification)

size = int(simulationScreen.magnification)

if size < 2:
pygame.draw.circle(simulationDisplay,constant.white,(x,y),1,1)
else:
pygame.draw.circle(simulationDisplay,constant.white,(x,y),size,0)

#Start menu

messageFunction("ApplePy",parameter.displayWidth/2,parameter.displayHeight/8)

messageFunction("n-body simulator",parameter.displayWidth/2,parameter.displayHeight/8 + 50)

button("Start!", parameter.displayWidth/2,parameter.displayHeight/2 - 150,100,50, constant.green,constant.darkGreen,simulationLoop)

button("Help", parameter.displayWidth/2,parameter.displayHeight/2 - 75,100,50, constant.green,constant.darkGreen,helpScreen)

button("About", parameter.displayWidth/2,parameter.displayHeight/2,100,50, constant.green,constant.darkGreen,aboutScreen)

pygame.display.update()
clock.tick(30)

#Simulation loop

#Initial conditions
simulator.generateParticles(parameter.particleNumber,"moon")

def simulationLoop():

count = 0

simulationExit = False

while not simulationExit:
for event in pygame.event.get():

#Handling quit events

if event.type == pygame.QUIT:
simulationExit = True

if event.type == pygame.KEYDOWN:
if event.key == pygame.K_r:
resetSimulation()
count = 0
elif event.key == pygame.K_SPACE:
pause(count)
elif event.key in functionKeys:
functionKeys[event.key](simulationScreen)

simulationDisplay.fill(constant.black)

#Update particle positions
simulator.updatePositions(simulator.particleList,"euler")

#Draw particles
for particle in simulator.particleList:

x = int(simulationScreen.mx + (simulationScreen.dx + particle.px) * simulationScreen.magnification)
y = int(simulationScreen.my + (simulationScreen.dy + particle.py) * simulationScreen.magnification)

size = int(simulationScreen.magnification)

if size < 2:
pygame.draw.circle(simulationDisplay,constant.white,(x,y),1,1)
else:
pygame.draw.circle(simulationDisplay,constant.white,(x,y),size,0)

count += 1
daysPassed(count)

pygame.display.update()

clock.tick(30)

pygame.quit()
quit()

#Simulation help screen
def helpScreen():

intro = True

while intro:

for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
quit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE:
intro = False
if event.key == pygame.K_r:
resetSimulation()
if event.key == pygame.K_q:
pygame.quit()
quit()
if event.key in functionKeys:
functionKeys[event.key](simulationScreen)

simulationDisplay.fill(constant.black)

#Draw initial particles
for particle in simulator.particleList:

x = int(simulationScreen.mx + (simulationScreen.dx + particle.px) * simulationScreen.magnification)
y = int(simulationScreen.my + (simulationScreen.dy + particle.py) * simulationScreen.magnification)

size = int(simulationScreen.magnification)

if size < 2:
pygame.draw.circle(simulationDisplay,constant.white,(x,y),1,1)
else:
pygame.draw.circle(simulationDisplay,constant.white,(x,y),size,0)

#Start menu

messageFunction("ApplePy",parameter.displayWidth/2,parameter.displayHeight/8)

messageFunction("n-body simulator",parameter.displayWidth/2,parameter.displayHeight/8 + 50)

messageFunction("Press spacebar to pause",parameter.displayWidth/2,parameter.displayHeight/8 + 150)

messageFunction("Use arrow keys to move around and +/- to zoom",parameter.displayWidth/2,parameter.displayHeight/8 + 200)

messageFunction("Press r to reset simulation and q to quit",parameter.displayWidth/2,parameter.displayHeight/8 + 250)

button("Back", parameter.displayWidth/2,parameter.displayHeight/8 + 350,100,50, constant.green,constant.darkGreen,simulationIntro)

pygame.display.update()
clock.tick(30)

#Simulation about screen
def aboutScreen():

intro = True

while intro:

for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
quit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE:
intro = False
if event.key == pygame.K_r:
resetSimulation()
if event.key == pygame.K_q:
pygame.quit()
quit()
if event.key in functionKeys:
functionKeys[event.key](simulationScreen)

simulationDisplay.fill(constant.black)

#Draw initial particles
for particle in simulator.particleList:

x = int(simulationScreen.mx + (simulationScreen.dx + particle.px) * simulationScreen.magnification)
y = int(simulationScreen.my + (simulationScreen.dy + particle.py) * simulationScreen.magnification)

size = int(simulationScreen.magnification)

if size < 2:
pygame.draw.circle(simulationDisplay,constant.white,(x,y),1,1)
else:
pygame.draw.circle(simulationDisplay,constant.white,(x,y),size,0)

#Start menu

messageFunction("ApplePy",parameter.displayWidth/2,parameter.displayHeight/8)

messageFunction("n-body simulator",parameter.displayWidth/2,parameter.displayHeight/8 + 50)

messageFunction("This physics simulation uses euler integration to solve",parameter.displayWidth/2,parameter.displayHeight/8 + 150)

messageFunction("for the motion of particles under the influence of gravity.",parameter.displayWidth/2,parameter.displayHeight/8 + 200)

messageFunction("Built by Paul Le",parameter.displayWidth/2,parameter.displayHeight/8 + 250)

button("Back", parameter.displayWidth/2,parameter.displayHeight/8 + 350,100,50, constant.green,constant.darkGreen,simulationIntro)

pygame.display.update()
clock.tick(30)


#Calling simulation program functions

simulationIntro()
simulationLoop()

{% endhighlight %}
60 changes: 0 additions & 60 deletions css/1syntax.css

This file was deleted.

0 comments on commit 72f6545

Please sign in to comment.