mirror of
https://github.com/processing/processing4.git
synced 2026-05-04 09:56:41 +02:00
adding basics folder to the android dist
This commit is contained in:
38
android/examples/Basics/Image/Sprite/Sprite.pde
Normal file
38
android/examples/Basics/Image/Sprite/Sprite.pde
Normal file
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Sprite (Teddy)
|
||||
* by James Patterson.
|
||||
*
|
||||
* Demonstrates loading and displaying a transparent GIF image.
|
||||
*/
|
||||
|
||||
PImage teddy;
|
||||
|
||||
float xpos;
|
||||
float ypos;
|
||||
float drag = 30;
|
||||
|
||||
void setup() {
|
||||
size(200, 200);
|
||||
teddy = loadImage("teddy.gif");
|
||||
xpos = width/2;
|
||||
ypos = height/2;
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(102);
|
||||
|
||||
float difx = mouseX - xpos-teddy.width/2;
|
||||
if (abs(difx) > 1) {
|
||||
xpos = xpos + difx/drag;
|
||||
xpos = constrain(xpos, 0, width-teddy.width);
|
||||
}
|
||||
|
||||
float dify = mouseY - ypos-teddy.height/2;
|
||||
if (abs(dify) > 1) {
|
||||
ypos = ypos + dify/drag;
|
||||
ypos = constrain(ypos, 0, height-teddy.height);
|
||||
}
|
||||
|
||||
// Display the sprite at the position xpos, ypos
|
||||
image(teddy, xpos, ypos);
|
||||
}
|
||||
61
android/examples/Basics/Image/Sprite/applet/Sprite.java
Normal file
61
android/examples/Basics/Image/Sprite/applet/Sprite.java
Normal file
@@ -0,0 +1,61 @@
|
||||
import processing.core.*;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class Sprite extends PApplet {
|
||||
|
||||
/**
|
||||
* Sprite (Teddy)
|
||||
* by James Patterson.
|
||||
*
|
||||
* Demonstrates loading and displaying a transparent GIF image.
|
||||
*/
|
||||
|
||||
PImage teddy;
|
||||
|
||||
float xpos;
|
||||
float ypos;
|
||||
float drag = 30.0f;
|
||||
|
||||
public void setup()
|
||||
{
|
||||
size(200,200);
|
||||
teddy = loadImage("teddy.gif");
|
||||
xpos = width/2;
|
||||
ypos = height/2;
|
||||
frameRate(60);
|
||||
}
|
||||
|
||||
public void draw()
|
||||
{
|
||||
background(102);
|
||||
|
||||
float difx = mouseX - xpos-teddy.width/2;
|
||||
if(abs(difx) > 1.0f) {
|
||||
xpos = xpos + difx/drag;
|
||||
xpos = constrain(xpos, 0, width-teddy.width);
|
||||
}
|
||||
|
||||
float dify = mouseY - ypos-teddy.height/2;
|
||||
if(abs(dify) > 1.0f) {
|
||||
ypos = ypos + dify/drag;
|
||||
ypos = constrain(ypos, 0, height-teddy.height);
|
||||
}
|
||||
|
||||
// Display the sprite at the position xpos, ypos
|
||||
image(teddy, xpos, ypos);
|
||||
}
|
||||
|
||||
static public void main(String args[]) {
|
||||
PApplet.main(new String[] { "Sprite" });
|
||||
}
|
||||
}
|
||||
41
android/examples/Basics/Image/Sprite/applet/Sprite.pde
Normal file
41
android/examples/Basics/Image/Sprite/applet/Sprite.pde
Normal file
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Sprite (Teddy)
|
||||
* by James Patterson.
|
||||
*
|
||||
* Demonstrates loading and displaying a transparent GIF image.
|
||||
*/
|
||||
|
||||
PImage teddy;
|
||||
|
||||
float xpos;
|
||||
float ypos;
|
||||
float drag = 30.0;
|
||||
|
||||
void setup()
|
||||
{
|
||||
size(200,200);
|
||||
teddy = loadImage("teddy.gif");
|
||||
xpos = width/2;
|
||||
ypos = height/2;
|
||||
frameRate(60);
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
background(102);
|
||||
|
||||
float difx = mouseX - xpos-teddy.width/2;
|
||||
if(abs(difx) > 1.0) {
|
||||
xpos = xpos + difx/drag;
|
||||
xpos = constrain(xpos, 0, width-teddy.width);
|
||||
}
|
||||
|
||||
float dify = mouseY - ypos-teddy.height/2;
|
||||
if(abs(dify) > 1.0) {
|
||||
ypos = ypos + dify/drag;
|
||||
ypos = constrain(ypos, 0, height-teddy.height);
|
||||
}
|
||||
|
||||
// Display the sprite at the position xpos, ypos
|
||||
image(teddy, xpos, ypos);
|
||||
}
|
||||
BIN
android/examples/Basics/Image/Sprite/applet/loading.gif
Normal file
BIN
android/examples/Basics/Image/Sprite/applet/loading.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
BIN
android/examples/Basics/Image/Sprite/data/teddy.gif
Normal file
BIN
android/examples/Basics/Image/Sprite/data/teddy.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 746 B |
Reference in New Issue
Block a user