<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:dc="https://purl.org/dc/elements/1.1/">
	<channel>
		<title><![CDATA[BP Forums - Code Snippets]]></title>
		<link>https://bpforums.info/</link>
		<description><![CDATA[BP Forums - https://bpforums.info]]></description>
		<pubDate>Tue, 05 May 2026 04:31:15 +0000</pubDate>
		<generator>MyBB</generator>
		<item>
			<title><![CDATA[Website Giveaway Program]]></title>
			<link>https://bpforums.info/showthread.php?tid=821</link>
			<pubDate>Mon, 06 Jan 2014 19:12:24 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://bpforums.info/member.php?action=profile&uid=1">brandonio21_phpbb3_import2</a>]]></dc:creator>
			<guid isPermaLink="false">https://bpforums.info/showthread.php?tid=821</guid>
			<description><![CDATA[Many of the viewers of the website giveaway video have requested that I share the source code of the program used. In order to heed these requests and ensure that everyone knows that the giveaway is fair, here is the code for the website giveaway program.<br />
<br />
Basically, it reads from a text file containing all the comments, parses the text file for usernames, and randomly selects one of them. Any forced waiting is simply for dramatic effect and time creation.<br />
<br />
The winner selector:<br />
[code2=java]import java.util.Scanner;<br />
import java.util.Random;<br />
import java.io.FileNotFoundException;<br />
import java.util.ArrayList;<br />
import java.io.File;<br />
public class comments<br />
{<br />
  private static ArrayList&lt;String&gt; commentList;<br />
  private static ArrayList&lt;String&gt; removeList;<br />
  public static void main(String[] args)<br />
  {<br />
    System.out.println("Welcome to the giveaway calculator!");<br />
    System.out.println("This is for use by BrandonioProductions for his");<br />
    System.out.println("2013-2014 website giveaway! Press &lt;ENTER&gt; to begin");<br />
    Scanner waiter = new Scanner(System.in);<br />
    waiter.nextLine();<br />
    System.out.println("First, gathering YouTube comments, please wait.");<br />
    for (int i = 0; i &lt; 5; i++)<br />
    {<br />
      System.out.print(".");<br />
      rest();<br />
    }<br />
    System.out.println(); <br />
    commentList = new ArrayList&lt;String&gt;();<br />
    removeList = new ArrayList&lt;String&gt;();<br />
    //First, we need to read from the file<br />
    try<br />
    {<br />
      Scanner reader = new Scanner(new File("comments.txt"));<br />
      reader.useDelimiter(System.getProperty("line.separator"));<br />
      while (reader.hasNext())<br />
      {<br />
        String line = reader.next();<br />
        if (line.contains("week"))<br />
        {<br />
          //This is a username<br />
          int ind = line.indexOf("1 week ago");<br />
          String username = line.substring(0, ind);<br />
          if (commentList.contains(username))<br />
            removeList.add(username);<br />
          else<br />
            commentList.add(username);<br />
        }<br />
      }<br />
      reader.close();<br />
    }<br />
    catch (FileNotFoundException e)<br />
    {<br />
      e.printStackTrace();<br />
    }<br />
    System.out.format("We found %d entries! Press &lt;ENTER&gt; to continue", commentList.size());<br />
    waiter.nextLine();<br />
    System.out.println("Removing duplicate entries, please wait..");<br />
    for (String s : removeList)<br />
      commentList.remove(s);<br />
    for (int i = 0; i &lt; 5; i ++)<br />
    {<br />
      System.out.print(".");<br />
      rest();<br />
    }<br />
    System.out.println();<br />
    System.out.println("We are good to go! Press &lt;ENTER&gt; to get the first winner!");<br />
    waiter.nextLine();<br />
    Random rnd = new Random();<br />
    int winner1 = rnd.nextInt(commentList.size());<br />
    System.out.format("The first winner has entry # of %d", winner1);<br />
    for (int i = 0; i &lt; 5; i++)<br />
    {<br />
      System.out.print(".");<br />
      rest();<br />
    }<br />
    System.out.println();<br />
    System.out.format("The first winner is: \n %s \n", commentList.get(winner1));<br />
    System.out.println("Press &lt;ENTER&gt; to get the second winner!");<br />
    waiter.nextLine();<br />
    int winner2 = rnd.nextInt(commentList.size());<br />
    System.out.format("The second winner has entry # of %d", winner2);<br />
    for (int i = 0; i &lt; 5; i++)<br />
    {<br />
      System.out.print(".");<br />
      rest();<br />
    }<br />
    System.out.println();<br />
    System.out.format("The second winner is: \n %s", commentList.get(winner2));<br />
  }<br />
<br />
  public static void rest()<br />
  {<br />
    try<br />
    {<br />
      Thread.currentThread();<br />
      Thread.sleep(1000);<br />
    }<br />
    catch (Exception e) {}<br />
  }<br />
}[/code2]<br />
<br />
<span style="font-weight: bold;" class="mycode_b">The text file is attached</span><br />
[attachment=0]&lt;!-- ia0 --&gt;comments.zip&lt;!-- ia0 --&gt;[/attachment]<br />
<br />
You can also find the program on Pastebin:<br />
&lt;!-- m --&gt;&lt;a class="postlink" href="http://pastebin.com/DzLdPzGc"&gt;http://pastebin.com/DzLdPzGc&lt;/a&gt;&lt;!-- m --&gt;<br /><!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://bpforums.info/images/attachtypes/zip.png" title="ZIP File" border="0" alt=".zip" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=135" target="_blank" title="">comments.zip</a> (Size: 5.58 KB / Downloads: 1082)
<!-- end: postbit_attachments_attachment -->]]></description>
			<content:encoded><![CDATA[Many of the viewers of the website giveaway video have requested that I share the source code of the program used. In order to heed these requests and ensure that everyone knows that the giveaway is fair, here is the code for the website giveaway program.<br />
<br />
Basically, it reads from a text file containing all the comments, parses the text file for usernames, and randomly selects one of them. Any forced waiting is simply for dramatic effect and time creation.<br />
<br />
The winner selector:<br />
[code2=java]import java.util.Scanner;<br />
import java.util.Random;<br />
import java.io.FileNotFoundException;<br />
import java.util.ArrayList;<br />
import java.io.File;<br />
public class comments<br />
{<br />
  private static ArrayList&lt;String&gt; commentList;<br />
  private static ArrayList&lt;String&gt; removeList;<br />
  public static void main(String[] args)<br />
  {<br />
    System.out.println("Welcome to the giveaway calculator!");<br />
    System.out.println("This is for use by BrandonioProductions for his");<br />
    System.out.println("2013-2014 website giveaway! Press &lt;ENTER&gt; to begin");<br />
    Scanner waiter = new Scanner(System.in);<br />
    waiter.nextLine();<br />
    System.out.println("First, gathering YouTube comments, please wait.");<br />
    for (int i = 0; i &lt; 5; i++)<br />
    {<br />
      System.out.print(".");<br />
      rest();<br />
    }<br />
    System.out.println(); <br />
    commentList = new ArrayList&lt;String&gt;();<br />
    removeList = new ArrayList&lt;String&gt;();<br />
    //First, we need to read from the file<br />
    try<br />
    {<br />
      Scanner reader = new Scanner(new File("comments.txt"));<br />
      reader.useDelimiter(System.getProperty("line.separator"));<br />
      while (reader.hasNext())<br />
      {<br />
        String line = reader.next();<br />
        if (line.contains("week"))<br />
        {<br />
          //This is a username<br />
          int ind = line.indexOf("1 week ago");<br />
          String username = line.substring(0, ind);<br />
          if (commentList.contains(username))<br />
            removeList.add(username);<br />
          else<br />
            commentList.add(username);<br />
        }<br />
      }<br />
      reader.close();<br />
    }<br />
    catch (FileNotFoundException e)<br />
    {<br />
      e.printStackTrace();<br />
    }<br />
    System.out.format("We found %d entries! Press &lt;ENTER&gt; to continue", commentList.size());<br />
    waiter.nextLine();<br />
    System.out.println("Removing duplicate entries, please wait..");<br />
    for (String s : removeList)<br />
      commentList.remove(s);<br />
    for (int i = 0; i &lt; 5; i ++)<br />
    {<br />
      System.out.print(".");<br />
      rest();<br />
    }<br />
    System.out.println();<br />
    System.out.println("We are good to go! Press &lt;ENTER&gt; to get the first winner!");<br />
    waiter.nextLine();<br />
    Random rnd = new Random();<br />
    int winner1 = rnd.nextInt(commentList.size());<br />
    System.out.format("The first winner has entry # of %d", winner1);<br />
    for (int i = 0; i &lt; 5; i++)<br />
    {<br />
      System.out.print(".");<br />
      rest();<br />
    }<br />
    System.out.println();<br />
    System.out.format("The first winner is: \n %s \n", commentList.get(winner1));<br />
    System.out.println("Press &lt;ENTER&gt; to get the second winner!");<br />
    waiter.nextLine();<br />
    int winner2 = rnd.nextInt(commentList.size());<br />
    System.out.format("The second winner has entry # of %d", winner2);<br />
    for (int i = 0; i &lt; 5; i++)<br />
    {<br />
      System.out.print(".");<br />
      rest();<br />
    }<br />
    System.out.println();<br />
    System.out.format("The second winner is: \n %s", commentList.get(winner2));<br />
  }<br />
<br />
  public static void rest()<br />
  {<br />
    try<br />
    {<br />
      Thread.currentThread();<br />
      Thread.sleep(1000);<br />
    }<br />
    catch (Exception e) {}<br />
  }<br />
}[/code2]<br />
<br />
<span style="font-weight: bold;" class="mycode_b">The text file is attached</span><br />
[attachment=0]&lt;!-- ia0 --&gt;comments.zip&lt;!-- ia0 --&gt;[/attachment]<br />
<br />
You can also find the program on Pastebin:<br />
&lt;!-- m --&gt;&lt;a class="postlink" href="http://pastebin.com/DzLdPzGc"&gt;http://pastebin.com/DzLdPzGc&lt;/a&gt;&lt;!-- m --&gt;<br /><!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://bpforums.info/images/attachtypes/zip.png" title="ZIP File" border="0" alt=".zip" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=135" target="_blank" title="">comments.zip</a> (Size: 5.58 KB / Downloads: 1082)
<!-- end: postbit_attachments_attachment -->]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Snake Game (Tutorial Edition)]]></title>
			<link>https://bpforums.info/showthread.php?tid=794</link>
			<pubDate>Mon, 24 Jun 2013 06:20:57 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://bpforums.info/member.php?action=profile&uid=1">brandonio21_phpbb3_import2</a>]]></dc:creator>
			<guid isPermaLink="false">https://bpforums.info/showthread.php?tid=794</guid>
			<description><![CDATA[So I just spent about 3 hours recording a 6-part tutorial series demonstrating how to make the classic game "snake" in Java. Although I still have to edit each video, upload it, make the code package, etc, I would like to share the final ideas with you early! <br />
<br />
The project consists of three main classes:<br />
**Direction - holds enumerations relating to the Â  Â direction that the snake can travel<br />
**snakeApplet - creates an applet that the canvas can run in<br />
**snakeCanvas - a canvas object that calculates all the snake game's logic and draws the game.<br />
<br />
<br />
<br />
So, when I previously made snake I had a difficulty figuring out how to make all of the body parts turn when they reached the point where the user pressed the arrow key. Well, I came to a realization when making this tutorial series. Instead of actually moving the various body parts across the grid, I could create a new head and delete the tail. This would resolve the issue of every body part actually having to turn and would allow for calculations to be much more efficient. Here's a visual of my new understanding:<br />
<!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://bpforums.info/images/attachtypes/image.png" title="PNG Image" border="0" alt=".png" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=126" target="_blank" title="">newSnakeLogic.png</a> (Size: 23.14 KB / Downloads: 4429)
<!-- end: postbit_attachments_attachment --><br />
<br />
Because of this, all calculations can now happen before any visualization is displayed. The tail is snipped and all calculations occur before the new head is placed.<br />
<br />
Watch the tutorial series starting with number one, found here:<br />
<a href="https://www.youtube.com/watch?v=FABTl1Q1byw&amp;list=PL13bz4SHGmRzIHoVh-B30U7jttLxYN_yi&amp;index=14" target="_blank" rel="noopener" class="mycode_url">https://www.youtube.com/watch?v=FABTl1Q1...i&amp;index=14</a><br />
<br />
<br />
Get the working source code here (Covers until part 6):<br />
<!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://bpforums.info/images/attachtypes/zip.png" title="ZIP File" border="0" alt=".zip" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=124" target="_blank" title="">SnakeTutorialSource.zip</a> (Size: 2.22 KB / Downloads: 4316)
<!-- end: postbit_attachments_attachment -->]]></description>
			<content:encoded><![CDATA[So I just spent about 3 hours recording a 6-part tutorial series demonstrating how to make the classic game "snake" in Java. Although I still have to edit each video, upload it, make the code package, etc, I would like to share the final ideas with you early! <br />
<br />
The project consists of three main classes:<br />
**Direction - holds enumerations relating to the Â  Â direction that the snake can travel<br />
**snakeApplet - creates an applet that the canvas can run in<br />
**snakeCanvas - a canvas object that calculates all the snake game's logic and draws the game.<br />
<br />
<br />
<br />
So, when I previously made snake I had a difficulty figuring out how to make all of the body parts turn when they reached the point where the user pressed the arrow key. Well, I came to a realization when making this tutorial series. Instead of actually moving the various body parts across the grid, I could create a new head and delete the tail. This would resolve the issue of every body part actually having to turn and would allow for calculations to be much more efficient. Here's a visual of my new understanding:<br />
<!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://bpforums.info/images/attachtypes/image.png" title="PNG Image" border="0" alt=".png" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=126" target="_blank" title="">newSnakeLogic.png</a> (Size: 23.14 KB / Downloads: 4429)
<!-- end: postbit_attachments_attachment --><br />
<br />
Because of this, all calculations can now happen before any visualization is displayed. The tail is snipped and all calculations occur before the new head is placed.<br />
<br />
Watch the tutorial series starting with number one, found here:<br />
<a href="https://www.youtube.com/watch?v=FABTl1Q1byw&amp;list=PL13bz4SHGmRzIHoVh-B30U7jttLxYN_yi&amp;index=14" target="_blank" rel="noopener" class="mycode_url">https://www.youtube.com/watch?v=FABTl1Q1...i&amp;index=14</a><br />
<br />
<br />
Get the working source code here (Covers until part 6):<br />
<!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://bpforums.info/images/attachtypes/zip.png" title="ZIP File" border="0" alt=".zip" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=124" target="_blank" title="">SnakeTutorialSource.zip</a> (Size: 2.22 KB / Downloads: 4316)
<!-- end: postbit_attachments_attachment -->]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[jBFCanvas]]></title>
			<link>https://bpforums.info/showthread.php?tid=785</link>
			<pubDate>Tue, 14 May 2013 05:20:32 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://bpforums.info/member.php?action=profile&uid=1">brandonio21_phpbb3_import2</a>]]></dc:creator>
			<guid isPermaLink="false">https://bpforums.info/showthread.php?tid=785</guid>
			<description><![CDATA[I have created a class which automatically implements and runs double-buffering. What does this mean? If you're making a game and want to utilize the mechanics of double-buffering, but don't know how, simply make your game class extend <span style="font-style: italic;" class="mycode_i">jBFCanvas</span> and you will have a working <span style="font-style: italic;" class="mycode_i">Canvas</span> object that automatically works as a double-buffering machine. Simply override the <span style="font-weight: bold;" class="mycode_b">DoLogic</span> and <span style="font-weight: bold;" class="mycode_b"><span style="font-style: italic;" class="mycode_i">Draw</span></span> methods! <br />
<br />
[code2=java]import java.awt.Canvas;<br />
import java.awt.Dimension;<br />
import java.awt.Graphics;<br />
import java.awt.Toolkit;<br />
import java.awt.image.BufferStrategy;<br />
<br />
/*<br />
 * This class is created to make making games easier, it allows<br />
 * classes to automatically inherit double-buffer capabilities and <br />
 * canvas properties<br />
 * To use, force your class to extend this class and override the draw and dologic methods<br />
 * created by brandonio21, Brandon Milton, &lt;!-- m --&gt;&lt;a class="postlink" href="http://brandonsoft.com"&gt;http://brandonsoft.com&lt;/a&gt;&lt;!-- m --&gt;<br />
 */<br />
public class jBFCanvas<br />
extends Canvas<br />
implements Runnable<br />
{<br />
<br />
	private static final long serialVersionUID = 1L;<br />
<br />
	private int waitTime;<br />
	<br />
	private BufferStrategy bfStrategy;<br />
	private Graphics bfGraphics;<br />
	<br />
	private Thread loopThread;<br />
	<br />
	public jBFCanvas(int waitTime, Dimension preferredSize)<br />
	{<br />
		this.waitTime = waitTime;<br />
		this.setPreferredSize(preferredSize);<br />
		<br />
		//constructor, we need to intialize the thread<br />
		if (loopThread == null)<br />
			loopThread = new Thread(this);<br />
	}<br />
	<br />
	public void paint(Graphics g)<br />
	{<br />
		//initialize backbuffer<br />
		if (bfStrategy == null)<br />
		{<br />
			this.createBufferStrategy(2);<br />
			bfStrategy = this.getBufferStrategy();<br />
		}<br />
		try<br />
		{<br />
			loopThread.start();<br />
		}<br />
		catch (Exception e) {} //this means the thread was already started. Don't do anything<br />
	}<br />
	<br />
	public void DoLogic()<br />
	{<br />
		//this is where apps calculations will go<br />
	}<br />
	<br />
	public void Draw(Graphics g)<br />
	{<br />
		//this is where all apps drawings will go<br />
	}<br />
	<br />
	public void Render()<br />
	{<br />
		bfStrategy = this.getBufferStrategy();<br />
		bfGraphics = null;<br />
		try<br />
		{<br />
			bfGraphics = bfStrategy.getDrawGraphics();<br />
			bfGraphics.clearRect(0, 0, this.getPreferredSize().width, this.getPreferredSize().height);<br />
			Draw(bfGraphics);<br />
		}<br />
		catch (Exception e) {}<br />
		finally<br />
		{<br />
			if (bfGraphics != null)<br />
				bfGraphics.dispose();<br />
		}<br />
		bfStrategy.show();<br />
		Toolkit.getDefaultToolkit().sync();<br />
	}<br />
	@Override<br />
	public void run() {<br />
		//loop. Ignore this<br />
				while (true)<br />
				{<br />
					DoLogic();<br />
					Render();<br />
					<br />
					//now we wait<br />
					Thread.currentThread();<br />
					try<br />
					{<br />
						Thread.sleep(waitTime);<br />
					}<br />
					catch (Exception e) {}<br />
				}<br />
		<br />
	}<br />
<br />
	public int getWaitTime() {<br />
		return waitTime;<br />
	}<br />
<br />
	public void setWaitTime(int waitTime) {<br />
		this.waitTime = waitTime;<br />
	}<br />
<br />
	public Graphics getGraphics() {<br />
		return bfGraphics;<br />
	}<br />
<br />
	public void setGraphics(Graphics bfGraphics) {<br />
		this.bfGraphics = bfGraphics;<br />
	}	<br />
	<br />
	<br />
}[/code2]<br />
<br />
Pastebin Link:<br />
&lt;!-- m --&gt;&lt;a class="postlink" href="http://pastebin.com/TjKbECee"&gt;http://pastebin.com/TjKbECee&lt;/a&gt;&lt;!-- m --&gt;]]></description>
			<content:encoded><![CDATA[I have created a class which automatically implements and runs double-buffering. What does this mean? If you're making a game and want to utilize the mechanics of double-buffering, but don't know how, simply make your game class extend <span style="font-style: italic;" class="mycode_i">jBFCanvas</span> and you will have a working <span style="font-style: italic;" class="mycode_i">Canvas</span> object that automatically works as a double-buffering machine. Simply override the <span style="font-weight: bold;" class="mycode_b">DoLogic</span> and <span style="font-weight: bold;" class="mycode_b"><span style="font-style: italic;" class="mycode_i">Draw</span></span> methods! <br />
<br />
[code2=java]import java.awt.Canvas;<br />
import java.awt.Dimension;<br />
import java.awt.Graphics;<br />
import java.awt.Toolkit;<br />
import java.awt.image.BufferStrategy;<br />
<br />
/*<br />
 * This class is created to make making games easier, it allows<br />
 * classes to automatically inherit double-buffer capabilities and <br />
 * canvas properties<br />
 * To use, force your class to extend this class and override the draw and dologic methods<br />
 * created by brandonio21, Brandon Milton, &lt;!-- m --&gt;&lt;a class="postlink" href="http://brandonsoft.com"&gt;http://brandonsoft.com&lt;/a&gt;&lt;!-- m --&gt;<br />
 */<br />
public class jBFCanvas<br />
extends Canvas<br />
implements Runnable<br />
{<br />
<br />
	private static final long serialVersionUID = 1L;<br />
<br />
	private int waitTime;<br />
	<br />
	private BufferStrategy bfStrategy;<br />
	private Graphics bfGraphics;<br />
	<br />
	private Thread loopThread;<br />
	<br />
	public jBFCanvas(int waitTime, Dimension preferredSize)<br />
	{<br />
		this.waitTime = waitTime;<br />
		this.setPreferredSize(preferredSize);<br />
		<br />
		//constructor, we need to intialize the thread<br />
		if (loopThread == null)<br />
			loopThread = new Thread(this);<br />
	}<br />
	<br />
	public void paint(Graphics g)<br />
	{<br />
		//initialize backbuffer<br />
		if (bfStrategy == null)<br />
		{<br />
			this.createBufferStrategy(2);<br />
			bfStrategy = this.getBufferStrategy();<br />
		}<br />
		try<br />
		{<br />
			loopThread.start();<br />
		}<br />
		catch (Exception e) {} //this means the thread was already started. Don't do anything<br />
	}<br />
	<br />
	public void DoLogic()<br />
	{<br />
		//this is where apps calculations will go<br />
	}<br />
	<br />
	public void Draw(Graphics g)<br />
	{<br />
		//this is where all apps drawings will go<br />
	}<br />
	<br />
	public void Render()<br />
	{<br />
		bfStrategy = this.getBufferStrategy();<br />
		bfGraphics = null;<br />
		try<br />
		{<br />
			bfGraphics = bfStrategy.getDrawGraphics();<br />
			bfGraphics.clearRect(0, 0, this.getPreferredSize().width, this.getPreferredSize().height);<br />
			Draw(bfGraphics);<br />
		}<br />
		catch (Exception e) {}<br />
		finally<br />
		{<br />
			if (bfGraphics != null)<br />
				bfGraphics.dispose();<br />
		}<br />
		bfStrategy.show();<br />
		Toolkit.getDefaultToolkit().sync();<br />
	}<br />
	@Override<br />
	public void run() {<br />
		//loop. Ignore this<br />
				while (true)<br />
				{<br />
					DoLogic();<br />
					Render();<br />
					<br />
					//now we wait<br />
					Thread.currentThread();<br />
					try<br />
					{<br />
						Thread.sleep(waitTime);<br />
					}<br />
					catch (Exception e) {}<br />
				}<br />
		<br />
	}<br />
<br />
	public int getWaitTime() {<br />
		return waitTime;<br />
	}<br />
<br />
	public void setWaitTime(int waitTime) {<br />
		this.waitTime = waitTime;<br />
	}<br />
<br />
	public Graphics getGraphics() {<br />
		return bfGraphics;<br />
	}<br />
<br />
	public void setGraphics(Graphics bfGraphics) {<br />
		this.bfGraphics = bfGraphics;<br />
	}	<br />
	<br />
	<br />
}[/code2]<br />
<br />
Pastebin Link:<br />
&lt;!-- m --&gt;&lt;a class="postlink" href="http://pastebin.com/TjKbECee"&gt;http://pastebin.com/TjKbECee&lt;/a&gt;&lt;!-- m --&gt;]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[RectangleImage]]></title>
			<link>https://bpforums.info/showthread.php?tid=782</link>
			<pubDate>Thu, 09 May 2013 23:08:54 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://bpforums.info/member.php?action=profile&uid=1">brandonio21_phpbb3_import2</a>]]></dc:creator>
			<guid isPermaLink="false">https://bpforums.info/showthread.php?tid=782</guid>
			<description><![CDATA[I have developed a small class which syncs a rectangle with an image, allowing the seamless detection of collisions within an image using an invisible rectangle, if you will. This is extremely useful for game objects such as players, bullets, enemies, etc.<br />
<br />
Hopefully you find it useful:<br />
[code2=java]class RectangleImage<br />
{<br />
	private Image img = null;<br />
	private Rectangle rect = null;<br />
	<br />
	public RectangleImage(Image img, int x, int y)<br />
	{<br />
		this.img = img;<br />
		ImageIcon icon = new ImageIcon(img);<br />
		this.rect = new Rectangle(x, y, icon.getIconWidth(), icon.getIconHeight());<br />
	}<br />
	<br />
	public Rectangle getRect()<br />
	{<br />
		return this.rect;<br />
	}<br />
	<br />
	public Image getImg()<br />
	{<br />
		return this.img;<br />
	}<br />
	<br />
	public void move(int x, int y)<br />
	{<br />
		this.rect.setBounds(x, y, rect.width, rect.height);<br />
	}<br />
	<br />
	public void draw(Graphics2D g2, ImageObserver o)<br />
	{<br />
		g2.drawImage(this.img, this.rect.x, this.rect.y, this.rect.width, this.rect.height, o);<br />
	}<br />
	<br />
	public boolean intersects(Rectangle r)<br />
	{<br />
		return this.rect.intersects&reg;;<br />
	}<br />
	<br />
	public Rectangle intersection(Rectangle r)<br />
	{<br />
		return this.rect.intersection&reg;;<br />
	}<br />
	<br />
	public void rotateImage(double degrees, ImageObserver o)<br />
	{<br />
		ImageIcon icon = new ImageIcon(this.img);<br />
		BufferedImage blankCanvas = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);<br />
		Graphics2D g2 = (Graphics2D)blankCanvas.getGraphics();<br />
		g2.rotate(Math.toRadians(degrees), icon.getIconWidth() / 2, icon.getIconHeight() / 2);<br />
		g2.drawImage(this.img, 0, 0, o);<br />
		this.img = blankCanvas;<br />
	}<br />
}[/code2]<br />
Pastebin link: &lt;!-- m --&gt;&lt;a class="postlink" href="http://pastebin.com/AC4aKBvx"&gt;http://pastebin.com/AC4aKBvx&lt;/a&gt;&lt;!-- m --&gt;<br />
Rotation Pastebin Link: &lt;!-- m --&gt;&lt;a class="postlink" href="http://pastebin.com/6S9ADmXH"&gt;http://pastebin.com/6S9ADmXH&lt;/a&gt;&lt;!-- m --&gt;<br />
<br />
The first tutorial on this code (moving images) can be seen here:<br />
&lt;!-- m --&gt;&lt;a class="postlink" href="http://www.youtube.com/watch?v=0MKLBh0fBbg&amp;feature=youtu.be"&gt;http://www.youtube.com/watch?v=0MKLBh0f ... e=youtu.be&lt;/a&gt;&lt;!-- m --&gt;<br />
<br />
The second tutorial on this code (collisions/intersections) can be seen here:<br />
&lt;!-- m --&gt;&lt;a class="postlink" href="http://www.youtube.com/watch?v=iO_RpUuDyeg&amp;feature=youtu.be"&gt;http://www.youtube.com/watch?v=iO_RpUuD ... e=youtu.be&lt;/a&gt;&lt;!-- m --&gt;<br />
<br />
The third tutorial on this code (rotation) can be seen here:<br />
&lt;!-- m --&gt;&lt;a class="postlink" href="http://www.youtube.com/watch?v=vxNBSVuNKrc&amp;feature=youtu.be"&gt;http://www.youtube.com/watch?v=vxNBSVuN ... e=youtu.be&lt;/a&gt;&lt;!-- m --&gt;<br />
<br />
Although the above code is used in the first three tutorials, I have since revised the code. <span style="font-weight: bold;" class="mycode_b">The updated version is:</span><br />
<br />
[code2=java]class RectangleImage extends Rectangle<br />
{<br />
        //RectangleImage class created by brandonio21 --<br />
        //allows seamless integration of positioning/rotation<br />
        //with images. Extremely useful for games.<br />
        //http://brandonsoft.com<br />
        private Image img = null;<br />
       <br />
        public RectangleImage(Image img, int x, int y)<br />
        {<br />
                this.img = img;<br />
                ImageIcon icon = new ImageIcon(img);<br />
                this.setBounds(x, y, icon.getIconWidth(), icon.getIconHeight());<br />
        }<br />
       <br />
        public Image getImg()<br />
        {<br />
                return this.img;<br />
        }<br />
       <br />
        public void move(int x, int y)<br />
        {<br />
                this.setBounds(x, y, width, height);<br />
        }<br />
       <br />
        public void draw(Graphics2D g2, ImageObserver o)<br />
        {<br />
                g2.drawImage(this.img, x, y, width, height, o);<br />
        }<br />
       <br />
        public void rotateImage(double degrees, ImageObserver o)<br />
        {<br />
                ImageIcon icon = new ImageIcon(this.img);<br />
                BufferedImage blankCanvas = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);<br />
                Graphics2D g2 = (Graphics2D)blankCanvas.getGraphics();<br />
                g2.rotate(Math.toRadians(degrees), icon.getIconWidth() / 2, icon.getIconHeight() / 2);<br />
                g2.drawImage(this.img, 0, 0, o);<br />
                this.img = blankCanvas;<br />
        }<br />
}[/code2]<br />
Revised Pastebin Link: &lt;!-- m --&gt;&lt;a class="postlink" href="http://pastebin.com/EdwqJE1g"&gt;http://pastebin.com/EdwqJE1g&lt;/a&gt;&lt;!-- m --&gt;<br />
Revised Class Video Discussion:<br />
&lt;!-- m --&gt;&lt;a class="postlink" href="http://www.youtube.com/watch?v=JZSs_bqRij8&amp;feature=youtu.be"&gt;http://www.youtube.com/watch?v=JZSs_bqR ... e=youtu.be&lt;/a&gt;&lt;!-- m --&gt;]]></description>
			<content:encoded><![CDATA[I have developed a small class which syncs a rectangle with an image, allowing the seamless detection of collisions within an image using an invisible rectangle, if you will. This is extremely useful for game objects such as players, bullets, enemies, etc.<br />
<br />
Hopefully you find it useful:<br />
[code2=java]class RectangleImage<br />
{<br />
	private Image img = null;<br />
	private Rectangle rect = null;<br />
	<br />
	public RectangleImage(Image img, int x, int y)<br />
	{<br />
		this.img = img;<br />
		ImageIcon icon = new ImageIcon(img);<br />
		this.rect = new Rectangle(x, y, icon.getIconWidth(), icon.getIconHeight());<br />
	}<br />
	<br />
	public Rectangle getRect()<br />
	{<br />
		return this.rect;<br />
	}<br />
	<br />
	public Image getImg()<br />
	{<br />
		return this.img;<br />
	}<br />
	<br />
	public void move(int x, int y)<br />
	{<br />
		this.rect.setBounds(x, y, rect.width, rect.height);<br />
	}<br />
	<br />
	public void draw(Graphics2D g2, ImageObserver o)<br />
	{<br />
		g2.drawImage(this.img, this.rect.x, this.rect.y, this.rect.width, this.rect.height, o);<br />
	}<br />
	<br />
	public boolean intersects(Rectangle r)<br />
	{<br />
		return this.rect.intersects&reg;;<br />
	}<br />
	<br />
	public Rectangle intersection(Rectangle r)<br />
	{<br />
		return this.rect.intersection&reg;;<br />
	}<br />
	<br />
	public void rotateImage(double degrees, ImageObserver o)<br />
	{<br />
		ImageIcon icon = new ImageIcon(this.img);<br />
		BufferedImage blankCanvas = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);<br />
		Graphics2D g2 = (Graphics2D)blankCanvas.getGraphics();<br />
		g2.rotate(Math.toRadians(degrees), icon.getIconWidth() / 2, icon.getIconHeight() / 2);<br />
		g2.drawImage(this.img, 0, 0, o);<br />
		this.img = blankCanvas;<br />
	}<br />
}[/code2]<br />
Pastebin link: &lt;!-- m --&gt;&lt;a class="postlink" href="http://pastebin.com/AC4aKBvx"&gt;http://pastebin.com/AC4aKBvx&lt;/a&gt;&lt;!-- m --&gt;<br />
Rotation Pastebin Link: &lt;!-- m --&gt;&lt;a class="postlink" href="http://pastebin.com/6S9ADmXH"&gt;http://pastebin.com/6S9ADmXH&lt;/a&gt;&lt;!-- m --&gt;<br />
<br />
The first tutorial on this code (moving images) can be seen here:<br />
&lt;!-- m --&gt;&lt;a class="postlink" href="http://www.youtube.com/watch?v=0MKLBh0fBbg&amp;feature=youtu.be"&gt;http://www.youtube.com/watch?v=0MKLBh0f ... e=youtu.be&lt;/a&gt;&lt;!-- m --&gt;<br />
<br />
The second tutorial on this code (collisions/intersections) can be seen here:<br />
&lt;!-- m --&gt;&lt;a class="postlink" href="http://www.youtube.com/watch?v=iO_RpUuDyeg&amp;feature=youtu.be"&gt;http://www.youtube.com/watch?v=iO_RpUuD ... e=youtu.be&lt;/a&gt;&lt;!-- m --&gt;<br />
<br />
The third tutorial on this code (rotation) can be seen here:<br />
&lt;!-- m --&gt;&lt;a class="postlink" href="http://www.youtube.com/watch?v=vxNBSVuNKrc&amp;feature=youtu.be"&gt;http://www.youtube.com/watch?v=vxNBSVuN ... e=youtu.be&lt;/a&gt;&lt;!-- m --&gt;<br />
<br />
Although the above code is used in the first three tutorials, I have since revised the code. <span style="font-weight: bold;" class="mycode_b">The updated version is:</span><br />
<br />
[code2=java]class RectangleImage extends Rectangle<br />
{<br />
        //RectangleImage class created by brandonio21 --<br />
        //allows seamless integration of positioning/rotation<br />
        //with images. Extremely useful for games.<br />
        //http://brandonsoft.com<br />
        private Image img = null;<br />
       <br />
        public RectangleImage(Image img, int x, int y)<br />
        {<br />
                this.img = img;<br />
                ImageIcon icon = new ImageIcon(img);<br />
                this.setBounds(x, y, icon.getIconWidth(), icon.getIconHeight());<br />
        }<br />
       <br />
        public Image getImg()<br />
        {<br />
                return this.img;<br />
        }<br />
       <br />
        public void move(int x, int y)<br />
        {<br />
                this.setBounds(x, y, width, height);<br />
        }<br />
       <br />
        public void draw(Graphics2D g2, ImageObserver o)<br />
        {<br />
                g2.drawImage(this.img, x, y, width, height, o);<br />
        }<br />
       <br />
        public void rotateImage(double degrees, ImageObserver o)<br />
        {<br />
                ImageIcon icon = new ImageIcon(this.img);<br />
                BufferedImage blankCanvas = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);<br />
                Graphics2D g2 = (Graphics2D)blankCanvas.getGraphics();<br />
                g2.rotate(Math.toRadians(degrees), icon.getIconWidth() / 2, icon.getIconHeight() / 2);<br />
                g2.drawImage(this.img, 0, 0, o);<br />
                this.img = blankCanvas;<br />
        }<br />
}[/code2]<br />
Revised Pastebin Link: &lt;!-- m --&gt;&lt;a class="postlink" href="http://pastebin.com/EdwqJE1g"&gt;http://pastebin.com/EdwqJE1g&lt;/a&gt;&lt;!-- m --&gt;<br />
Revised Class Video Discussion:<br />
&lt;!-- m --&gt;&lt;a class="postlink" href="http://www.youtube.com/watch?v=JZSs_bqRij8&amp;feature=youtu.be"&gt;http://www.youtube.com/watch?v=JZSs_bqR ... e=youtu.be&lt;/a&gt;&lt;!-- m --&gt;]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Loading and Displaying Images]]></title>
			<link>https://bpforums.info/showthread.php?tid=763</link>
			<pubDate>Thu, 21 Mar 2013 23:44:01 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://bpforums.info/member.php?action=profile&uid=1">brandonio21_phpbb3_import2</a>]]></dc:creator>
			<guid isPermaLink="false">https://bpforums.info/showthread.php?tid=763</guid>
			<description><![CDATA[This is the source code for my Java tutorial discussing how to load and display images in a Java applet.<br />
<br />
Here's the video:<br />
&lt;!-- m --&gt;&lt;a class="postlink" href="http://www.youtube.com/watch?v=oXmUp4ZTW2Q"&gt;http://www.youtube.com/watch?v=oXmUp4ZTW2Q&lt;/a&gt;&lt;!-- m --&gt;<br />
<br />
Source code:<br />
[code2=java]import java.applet.Applet;<br />
import java.awt.Graphics;<br />
import java.awt.Graphics2D;<br />
import java.awt.Image;<br />
import java.awt.Toolkit;<br />
import java.net.URL;<br />
<br />
public class ImageLoadingTutorial extends Applet<br />
{<br />
	<br />
	private Image spiral = null;<br />
	<br />
	public void paint(Graphics g) <br />
	{<br />
		this.setSize(640, 480);<br />
		<br />
		if (spiral == null)<br />
			spiral = getImage("spiral.png");<br />
		<br />
		Graphics2D g2 = (Graphics2D)g;<br />
		g2.drawImage(spiral, 25, 50, 25, 25, this);<br />
	}<br />
	<br />
	<br />
	public Image getImage(String path)<br />
	{<br />
		Image tempImage = null;<br />
		try<br />
		{<br />
			URL imageURL = ImageLoadingTutorial.class.getResource(path);<br />
			tempImage = Toolkit.getDefaultToolkit().getImage(imageURL);<br />
		}<br />
		catch (Exception e)<br />
		{<br />
			System.out.println("An error occured - " + e.getMessage());<br />
		}<br />
		return tempImage;<br />
	}<br />
	<br />
}[/code2]<br />
<br />
Pastebin link: &lt;!-- m --&gt;&lt;a class="postlink" href="http://pastebin.com/sdBqqdxK"&gt;http://pastebin.com/sdBqqdxK&lt;/a&gt;&lt;!-- m --&gt;]]></description>
			<content:encoded><![CDATA[This is the source code for my Java tutorial discussing how to load and display images in a Java applet.<br />
<br />
Here's the video:<br />
&lt;!-- m --&gt;&lt;a class="postlink" href="http://www.youtube.com/watch?v=oXmUp4ZTW2Q"&gt;http://www.youtube.com/watch?v=oXmUp4ZTW2Q&lt;/a&gt;&lt;!-- m --&gt;<br />
<br />
Source code:<br />
[code2=java]import java.applet.Applet;<br />
import java.awt.Graphics;<br />
import java.awt.Graphics2D;<br />
import java.awt.Image;<br />
import java.awt.Toolkit;<br />
import java.net.URL;<br />
<br />
public class ImageLoadingTutorial extends Applet<br />
{<br />
	<br />
	private Image spiral = null;<br />
	<br />
	public void paint(Graphics g) <br />
	{<br />
		this.setSize(640, 480);<br />
		<br />
		if (spiral == null)<br />
			spiral = getImage("spiral.png");<br />
		<br />
		Graphics2D g2 = (Graphics2D)g;<br />
		g2.drawImage(spiral, 25, 50, 25, 25, this);<br />
	}<br />
	<br />
	<br />
	public Image getImage(String path)<br />
	{<br />
		Image tempImage = null;<br />
		try<br />
		{<br />
			URL imageURL = ImageLoadingTutorial.class.getResource(path);<br />
			tempImage = Toolkit.getDefaultToolkit().getImage(imageURL);<br />
		}<br />
		catch (Exception e)<br />
		{<br />
			System.out.println("An error occured - " + e.getMessage());<br />
		}<br />
		return tempImage;<br />
	}<br />
	<br />
}[/code2]<br />
<br />
Pastebin link: &lt;!-- m --&gt;&lt;a class="postlink" href="http://pastebin.com/sdBqqdxK"&gt;http://pastebin.com/sdBqqdxK&lt;/a&gt;&lt;!-- m --&gt;]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Prime Finder]]></title>
			<link>https://bpforums.info/showthread.php?tid=756</link>
			<pubDate>Sun, 10 Mar 2013 03:36:47 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://bpforums.info/member.php?action=profile&uid=0">WitherSlayer</a>]]></dc:creator>
			<guid isPermaLink="false">https://bpforums.info/showthread.php?tid=756</guid>
			<description><![CDATA[This program will ask you for a number and then it will tell you if your number is prime or not.<br />
<br />
[code2=java]import java.util.Scanner;<br />
<br />
<br />
public class primeFinder {<br />
<br />
	static Scanner scanner = new Scanner(System.in);<br />
	<br />
<br />
	public static void main(String[] args)<br />
	{<br />
		System.out.println("What number would you like to find if it is prime or not:");<br />
		<br />
		int userNum = scanner.nextInt();<br />
	    int i;<br />
	    <br />
	    for (i = 2; i &lt; userNum;i++)<br />
	    {<br />
	    	<br />
	      int g = userNum % i;<br />
	      <br />
	      if (g == 0)<br />
	      {<br />
	        System.out.println("Your number is not prime!");<br />
	        break;<br />
	      }<br />
	    }<br />
	    if(i == userNum)<br />
	    {<br />
	      System.out.println("Your number is prime!");<br />
	    }		<br />
	}<br />
}[/code2]]]></description>
			<content:encoded><![CDATA[This program will ask you for a number and then it will tell you if your number is prime or not.<br />
<br />
[code2=java]import java.util.Scanner;<br />
<br />
<br />
public class primeFinder {<br />
<br />
	static Scanner scanner = new Scanner(System.in);<br />
	<br />
<br />
	public static void main(String[] args)<br />
	{<br />
		System.out.println("What number would you like to find if it is prime or not:");<br />
		<br />
		int userNum = scanner.nextInt();<br />
	    int i;<br />
	    <br />
	    for (i = 2; i &lt; userNum;i++)<br />
	    {<br />
	    	<br />
	      int g = userNum % i;<br />
	      <br />
	      if (g == 0)<br />
	      {<br />
	        System.out.println("Your number is not prime!");<br />
	        break;<br />
	      }<br />
	    }<br />
	    if(i == userNum)<br />
	    {<br />
	      System.out.println("Your number is prime!");<br />
	    }		<br />
	}<br />
}[/code2]]]></content:encoded>
		</item>
	</channel>
</rss>