Sprite flipping added

Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com>
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
main
unknown 3 years ago
parent 4b304f0062
commit 3310a549c2
  1. 10
      Java/scripts/md5
  2. 8
      README.md
  3. 54
      src/sig/DrawLoop.java
  4. 16
      src/sig/engine/Object.java
  5. 8
      src/sig/engine/Transform.java
  6. 13
      src/sig/objects/LevelRenderer.java
  7. 12
      src/sig/objects/Player.java
  8. 2
      utils/filelist
  9. 8
      utils/md5

@ -1,5 +1,5 @@
build.sh:55f0208b07ba384f45009d6f92fe88fe - build.sh:55f0208b07ba384f45009d6f92fe88fe *-
clean.sh:96ce35f2d2dcb555421e00a6afda23ca - clean.sh:96ce35f2d2dcb555421e00a6afda23ca *-
commit.sh:5e4448db9ad48e72ec3a1ff4f5763b41 - commit.sh:5e4448db9ad48e72ec3a1ff4f5763b41 *-
jar.sh:56f9b7c6dc8e85f28ffefe9ce82b1f07 - jar.sh:56f9b7c6dc8e85f28ffefe9ce82b1f07 *-
update.sh:3be721658983183efa395984acd96b03 - update.sh:3be721658983183efa395984acd96b03 *-

@ -30,6 +30,14 @@ Mizue (みずえ) 水恵
Turn off inline hints: (F1, search "Preferences: Open Settings (JSON)) "editor.inlayHints.enabled": false Turn off inline hints: (F1, search "Preferences: Open Settings (JSON)) "editor.inlayHints.enabled": false
Profont: 7x14 per tile. Profont: 7x14 per tile.
Belly Flop -> Slide
Sprint leads into Belly Slide
Underwater / Water Dashing (Propelling motion)
Air Dash (Water Dash-powerup)
Side Roll -> Slide
Wall Jumping
Movement Systems Movement Systems
Collectibles Collectibles
Combat Systems Combat Systems

@ -9,6 +9,7 @@ import sig.engine.PaletteColor;
import sig.engine.Panel; import sig.engine.Panel;
import sig.engine.Rectangle; import sig.engine.Rectangle;
import sig.engine.Sprite; import sig.engine.Sprite;
import sig.engine.Transform;
public class DrawLoop { public class DrawLoop {
public static Panel panel; public static Panel panel;
@ -61,56 +62,85 @@ public class DrawLoop {
yOffset+=f.getGlyphHeight(); yOffset+=f.getGlyphHeight();
charCount=0; charCount=0;
} else { } else {
Draw_Sprite_Partial_Ext(x+i*f.getGlyphWidth()-xOffset, y+yOffset, f.getCharInfo(finalS.charAt(i)).getX(), f.getCharInfo(finalS.charAt(i)).getY(), f.getCharInfo(finalS.charAt(i)).getWidth(), f.getCharInfo(finalS.charAt(i)).getHeight(), f.getSprite(), 0,alpha,currentCol); Draw_Sprite_Partial_Ext(x+i*f.getGlyphWidth()-xOffset, y+yOffset, f.getCharInfo(finalS.charAt(i)).getX(), f.getCharInfo(finalS.charAt(i)).getY(), f.getCharInfo(finalS.charAt(i)).getWidth(), f.getCharInfo(finalS.charAt(i)).getHeight(), f.getSprite(), 0,alpha,currentCol,Transform.NONE);
charCount++; charCount++;
} }
} }
} }
public static void Draw_Sprite(double x, double y, Sprite sprite){ public static void Draw_Sprite(double x, double y, Sprite sprite){
Draw_Sprite_Partial(x,y,0,0,sprite.getWidth(),sprite.getHeight(),sprite,0); Draw_Sprite_Partial(x,y,0,0,sprite.getWidth(),sprite.getHeight(),sprite,0,Transform.NONE );
} }
public static void Draw_Animated_Sprite(double x, double y, AnimatedSprite sprite, double frameIndex){ public static void Draw_Animated_Sprite(double x, double y, AnimatedSprite sprite, double frameIndex){
Rectangle frameRectangle=sprite.getFrame((int)frameIndex); Rectangle frameRectangle=sprite.getFrame((int)frameIndex);
Draw_Sprite_Partial(x,y,frameRectangle.getX(),frameRectangle.getY(),frameRectangle.getWidth(),frameRectangle.getHeight(),sprite,frameIndex); Draw_Sprite_Partial(x,y,frameRectangle.getX(),frameRectangle.getY(),frameRectangle.getWidth(),frameRectangle.getHeight(),sprite,frameIndex,Transform.NONE);
} }
public static void Draw_Sprite_Partial(double x, double y, double xOffset, double yOffset, double w, double h, Sprite sprite, double frame_index){ public static void Draw_Sprite(double x, double y, Sprite sprite, Transform transform){
Draw_Sprite_Partial(x,y,0,0,sprite.getWidth(),sprite.getHeight(),sprite,0,transform);
}
public static void Draw_Animated_Sprite(double x, double y, AnimatedSprite sprite, double frameIndex,Transform transform){
Rectangle frameRectangle=sprite.getFrame((int)frameIndex);
Draw_Sprite_Partial(x,y,frameRectangle.getX(),frameRectangle.getY(),frameRectangle.getWidth(),frameRectangle.getHeight(),sprite,frameIndex, transform);
}
public static void Draw_Sprite_Partial(double x, double y, double xOffset, double yOffset, double w, double h, Sprite sprite, double frame_index, Transform transform){
boolean horizontal = transform==Transform.HORIZONTAL||transform==Transform.HORIZ_VERTIC;
boolean vertical = transform==Transform.VERTICAL||transform==Transform.HORIZ_VERTIC;
byte[] p = panel.pixel; byte[] p = panel.pixel;
for(int X=(int)xOffset;X<(int)(w+xOffset);X++){ for(int X=(int)xOffset;X<(int)(w+xOffset);X++){
for(int Y=(int)yOffset;Y<(int)(h+yOffset);Y++){ for(int Y=(int)yOffset;Y<(int)(h+yOffset);Y++){
if (X+x-xOffset<0||Y+y-yOffset<0||X-xOffset+x>=RabiClone.BASE_WIDTH||Y-yOffset+y>=RabiClone.BASE_HEIGHT) { if (X+x-xOffset<0||Y+y-yOffset<0||X-xOffset+x>=RabiClone.BASE_WIDTH||Y-yOffset+y>=RabiClone.BASE_HEIGHT) {
continue; continue;
} else { } else {
int index = (Y-(int)yOffset+(int)y)*RabiClone.BASE_WIDTH+X-(int)xOffset+(int)x; int index =
((vertical?
sprite.getHeight()-(Y-(int)yOffset):
(Y-(int)yOffset))
+(int)y)*RabiClone.BASE_WIDTH+
(horizontal?
sprite.getWidth()-(X-(int)xOffset):
(X-(int)xOffset))
+(int)x;
if (index<0||index>=p.length||sprite.getBi_array()[Y*sprite.getCanvasWidth()+X]==32||p[index]==sprite.getBi_array()[Y*sprite.getCanvasWidth()+X]) { if (index<0||index>=p.length||sprite.getBi_array()[Y*sprite.getCanvasWidth()+X]==32||p[index]==sprite.getBi_array()[Y*sprite.getCanvasWidth()+X]) {
continue; continue;
} else { } else {
Draw(p,index,sprite.getBi_array()[Y*sprite.getCanvasWidth()+X],Alpha.ALPHA0); Draw(p,index,sprite.getBi_array()[Y*sprite.getCanvasWidth()+X],Alpha.ALPHA0);
} }
} }
} }
} }
} }
public static void Draw_Sprite_Partial_Ext(double x, double y, double xOffset, double yOffset, double w, double h, Sprite sprite, Alpha alpha){ public static void Draw_Sprite_Partial_Ext(double x, double y, double xOffset, double yOffset, double w, double h, Sprite sprite, Alpha alpha, Transform transform){
Draw_Sprite_Partial_Ext(x, y, xOffset, yOffset, w, h, sprite, 0, alpha, PaletteColor.NORMAL); Draw_Sprite_Partial_Ext(x, y, xOffset, yOffset, w, h, sprite, 0, alpha, PaletteColor.NORMAL, Transform.NONE);
} }
public static void Draw_Animated_Sprite_Partial_Ext(double x, double y, double xOffset, double yOffset, double w, double h, AnimatedSprite sprite, double frameIndex, Alpha alpha){ public static void Draw_Animated_Sprite_Partial_Ext(double x, double y, double xOffset, double yOffset, double w, double h, AnimatedSprite sprite, double frameIndex, Alpha alpha, Transform transform){
Rectangle frameRectangle=sprite.getFrame((int)frameIndex); Rectangle frameRectangle=sprite.getFrame((int)frameIndex);
Draw_Sprite_Partial_Ext(x, y, frameRectangle.getX(), frameRectangle.getY(), frameRectangle.getWidth(), frameRectangle.getHeight(), sprite, 0, alpha, PaletteColor.NORMAL); Draw_Sprite_Partial_Ext(x, y, frameRectangle.getX(), frameRectangle.getY(), frameRectangle.getWidth(), frameRectangle.getHeight(), sprite, 0, alpha, PaletteColor.NORMAL, Transform.NONE);
} }
public static void Draw_Sprite_Partial_Ext(double x, double y, double xOffset, double yOffset, double w, double h, Sprite sprite, double frame_index, Alpha alpha, PaletteColor col){ public static void Draw_Sprite_Partial_Ext(double x, double y, double xOffset, double yOffset, double w, double h, Sprite sprite, double frame_index, Alpha alpha, PaletteColor col, Transform transform){
boolean horizontal = transform==Transform.HORIZONTAL||transform==Transform.HORIZ_VERTIC;
boolean vertical = transform==Transform.VERTICAL||transform==Transform.HORIZ_VERTIC;
byte[] p = panel.pixel; byte[] p = panel.pixel;
for(int X=(int)xOffset;X<(int)(w+xOffset);X++){ for(int X=(int)xOffset;X<(int)(w+xOffset);X++){
for(int Y=(int)yOffset;Y<(int)(h+yOffset);Y++){ for(int Y=(int)yOffset;Y<(int)(h+yOffset);Y++){
if (X+x-xOffset<0||Y+y-yOffset<0||X-xOffset+x>=RabiClone.BASE_WIDTH||Y-yOffset+y>=RabiClone.BASE_HEIGHT) { if (X+x-xOffset<0||Y+y-yOffset<0||X-xOffset+x>=RabiClone.BASE_WIDTH||Y-yOffset+y>=RabiClone.BASE_HEIGHT) {
continue; continue;
} else { } else {
int index = (Y-(int)yOffset+(int)y)*RabiClone.BASE_WIDTH+X-(int)xOffset+(int)x; int index =
((vertical?
sprite.getHeight()-(Y-(int)yOffset):
(Y-(int)yOffset))
+(int)y)*RabiClone.BASE_WIDTH+
(horizontal?
sprite.getWidth()-(X-(int)xOffset):
(X-(int)xOffset))
+(int)x;
if (index<0||index>=p.length||sprite.getBi_array()[Y*sprite.getCanvasWidth()+X]==32||p[index]==sprite.getBi_array()[Y*sprite.getCanvasWidth()+X]) { if (index<0||index>=p.length||sprite.getBi_array()[Y*sprite.getCanvasWidth()+X]==32||p[index]==sprite.getBi_array()[Y*sprite.getCanvasWidth()+X]) {
continue; continue;
} else { } else {

@ -65,6 +65,10 @@ public abstract class Object implements GameEntity{
DrawLoop.Draw_Animated_Sprite(x,y,sprite,frameIndex); DrawLoop.Draw_Animated_Sprite(x,y,sprite,frameIndex);
} }
protected void Draw_Animated_Sprite(double x, double y, AnimatedSprite sprite, double frameIndex, Transform transform){
DrawLoop.Draw_Animated_Sprite(x,y,sprite,frameIndex,transform);
}
protected void Draw_Text(double x, double y, StringBuilder string, Font font){ protected void Draw_Text(double x, double y, StringBuilder string, Font font){
DrawLoop.Draw_Text(x,y,string,font); DrawLoop.Draw_Text(x,y,string,font);
} }
@ -73,16 +77,16 @@ public abstract class Object implements GameEntity{
DrawLoop.Draw_Text_Ext(x,y,string,font,alpha,col); DrawLoop.Draw_Text_Ext(x,y,string,font,alpha,col);
} }
protected void Draw_Sprite_Partial(double x, double y, double xOffset, double yOffset, double w, double h, Sprite sprite, double frame_index){ protected void Draw_Sprite_Partial(double x, double y, double xOffset, double yOffset, double w, double h, Sprite sprite, double frame_index, Transform transform){
DrawLoop.Draw_Sprite_Partial(x,y,xOffset,yOffset,w,h,sprite,frame_index); DrawLoop.Draw_Sprite_Partial(x,y,xOffset,yOffset,w,h,sprite,frame_index,transform);
} }
protected void Draw_Sprite_Partial_Ext(double x, double y, double xOffset, double yOffset, double w, double h, Sprite sprite, Alpha alpha){ protected void Draw_Sprite_Partial_Ext(double x, double y, double xOffset, double yOffset, double w, double h, Sprite sprite, Alpha alpha,Transform transform){
DrawLoop.Draw_Sprite_Partial_Ext(x,y,xOffset,yOffset,w,h,sprite,alpha); DrawLoop.Draw_Sprite_Partial_Ext(x,y,xOffset,yOffset,w,h,sprite,alpha,transform);
} }
protected void Draw_Sprite_Partial_Ext(double x, double y, double xOffset, double yOffset, double w, double h, Sprite sprite, double frame_index, Alpha alpha, PaletteColor col){ protected void Draw_Sprite_Partial_Ext(double x, double y, double xOffset, double yOffset, double w, double h, Sprite sprite, double frame_index, Alpha alpha, PaletteColor col,Transform transform){
DrawLoop.Draw_Sprite_Partial_Ext(x,y,xOffset,yOffset,w,h,sprite,frame_index,alpha,col); DrawLoop.Draw_Sprite_Partial_Ext(x,y,xOffset,yOffset,w,h,sprite,frame_index,alpha,col,transform);
} }
protected boolean KeyHeld(int key) { protected boolean KeyHeld(int key) {

@ -0,0 +1,8 @@
package sig.engine;
public enum Transform {
NONE,
HORIZONTAL,
VERTICAL,
HORIZ_VERTIC
}

@ -6,6 +6,7 @@ import sig.engine.AnimatedObject;
import sig.engine.Object; import sig.engine.Object;
import sig.engine.Panel; import sig.engine.Panel;
import sig.engine.Sprite; import sig.engine.Sprite;
import sig.engine.Transform;
import sig.map.Background; import sig.map.Background;
import sig.map.Map; import sig.map.Map;
import sig.map.Tile; import sig.map.Tile;
@ -37,7 +38,7 @@ public class LevelRenderer extends Object{
} }
} }
if (RabiClone.player!=null) { if (RabiClone.player!=null) {
Draw_Animated_Object(RabiClone.player); Draw_Animated_Object(RabiClone.player,RabiClone.player.facing_direction?Transform.HORIZONTAL:Transform.NONE);
} }
} }
@ -67,15 +68,19 @@ public class LevelRenderer extends Object{
} }
protected void Draw_Animated_Object(AnimatedObject object) { protected void Draw_Animated_Object(AnimatedObject object) {
super.Draw_Animated_Sprite(object.getX()-this.getX()-object.getAnimatedSpr().getWidth()/2, Math.round(object.getY()-this.getY()-object.getAnimatedSpr().getHeight()/2), object.getAnimatedSpr(), object.getCurrentFrame()); Draw_Animated_Object(object,Transform.NONE);
}
protected void Draw_Animated_Object(AnimatedObject object, Transform transform){
super.Draw_Animated_Sprite(object.getX()-this.getX()-object.getAnimatedSpr().getWidth()/2, Math.round(object.getY()-this.getY()-object.getAnimatedSpr().getHeight()/2), object.getAnimatedSpr(), object.getCurrentFrame(), transform);
} }
private void DrawTile(double x, double y, Tile tile) { private void DrawTile(double x, double y, Tile tile) {
Draw_Sprite_Partial(x,y, tile.getSpriteSheetX()*tile.getTileWidth(), tile.getSpriteSheetY()*tile.getTileHeight(), tile.getTileWidth(), tile.getTileHeight(), getSprite(), 0); Draw_Sprite_Partial(x,y, tile.getSpriteSheetX()*tile.getTileWidth(), tile.getSpriteSheetY()*tile.getTileHeight(), tile.getTileWidth(), tile.getTileHeight(), getSprite(), 0, Transform.NONE);
} }
protected void DrawTransparentTile(double x, double y, Tile tile, Alpha alpha) { protected void DrawTransparentTile(double x, double y, Tile tile, Alpha alpha) {
Draw_Sprite_Partial_Ext(x,y, tile.getSpriteSheetX()*tile.getTileWidth(), tile.getSpriteSheetY()*tile.getTileHeight(), tile.getTileWidth(), tile.getTileHeight(), getSprite(), alpha); Draw_Sprite_Partial_Ext(x,y, tile.getSpriteSheetX()*tile.getTileWidth(), tile.getSpriteSheetY()*tile.getTileHeight(), tile.getTileWidth(), tile.getTileHeight(), getSprite(), alpha, Transform.NONE);
} }
} }

@ -16,6 +16,8 @@ import java.awt.event.KeyEvent;
public class Player extends AnimatedObject{ public class Player extends AnimatedObject{
final double GRAVITY = 890; final double GRAVITY = 890;
final double NORMAL_FRICTION = 6400; final double NORMAL_FRICTION = 6400;
final boolean LEFT = false;
final boolean RIGHT = true;
double y_acceleration = GRAVITY; double y_acceleration = GRAVITY;
double y_acceleration_limit = 100; double y_acceleration_limit = 100;
@ -43,6 +45,7 @@ public class Player extends AnimatedObject{
boolean groundCollision = false; boolean groundCollision = false;
boolean spacebarReleased = true; boolean spacebarReleased = true;
boolean facing_direction = RIGHT;
long spacebarPressed = System.currentTimeMillis(); long spacebarPressed = System.currentTimeMillis();
int jumpHoldTime = 150; int jumpHoldTime = 150;
@ -68,7 +71,6 @@ public class Player extends AnimatedObject{
case IDLE: case IDLE:
break; break;
case JUMP: case JUMP:
break; break;
case SLIDE: case SLIDE:
break; break;
@ -130,6 +132,14 @@ public class Player extends AnimatedObject{
//System.out.println("Jump"); //System.out.println("Jump");
} }
} }
switch(key){
case KeyEvent.VK_LEFT: case KeyEvent.VK_A:
facing_direction=LEFT;
break;
case KeyEvent.VK_RIGHT:case KeyEvent.VK_D:
facing_direction=RIGHT;
break;
}
} }

@ -1,5 +1,5 @@
.coauthors .coauthors
.updateDirectories
define.sh define.sh
main.sh main.sh
search.sh search.sh
.updateDirectories

@ -1,4 +1,4 @@
define.sh:883c4033be11b6d1268b852beada5463 - .updateDirectories:0ede00461e947494545e694040787b3f *-
main.sh:fc4cd98b146e394539bdeeeb1491ff04 - define.sh:883c4033be11b6d1268b852beada5463 *-
search.sh:248d94cca6eeb92c384e9c49c9d0f4a9 - main.sh:fc4cd98b146e394539bdeeeb1491ff04 *-
.updateDirectories:0ede00461e947494545e694040787b3f - search.sh:248d94cca6eeb92c384e9c49c9d0f4a9 *-

Loading…
Cancel
Save