To advance my coding to a great level of understanding
my questions or resources you have used to solve these promblems yourself would be apprechiated.
My First Problem - Is that now that i have added the background as using the system.assembly the chracters are no longer constrained
My code was a
if ((e.KeyCode == System.Windows.Forms.Keys.Up && ChrYpoint != 0))
{
ChrYpoint -= ChrYSpeed = 10;
Invalidate();
}
and the same for the maxinum constraint for my form - and it worked before adding the background image.
--------------------------------------------------------------------------------------
My secound problem is that my form no longer changes when using the system.assembly.
using this code.
AllAloneLvOne Fr1 = new AllAloneLvOne();
Fr1.Show();
keeps showing my title image before my main game is started. and does not draw images afterwards.
And i cannot make more lvs without being able to go to another form.
--------------------------------------------------------------------------------------
My next Problem is collsion detection i am not sure what i am doing regarding this as i have never used collison detection and require some collison code or a resource to some simple to understand code.
My attempt was.
If(Image.Width = Image2.Width)
{
do event
}
-------------------------------------------------------------------------------------
My forth Problem
Is how to make my white box on my image disapper( to make the background show directly underneath the image - instead of the white box excess when making the image in paint.
--------------------------------------------------------------------------------------
My firth problem is how do i change my image as it moves - to allow light animation effect to make my game more intresting.
--------------------------------------------------------------------------------------
My sixth problem is that when my images are drawn the form (background colour flashes over my images). - Possibly releated to buffering (and using the double buffer which is currently absent from my code.
The most important ones to solve are 1 -3 - the others don;t matter as much immediatly but eventually i would like to know how to fix these also to extend my knowledge. Please help me - in any way to solve the 1-3 mysteries of the black magic box.
-----------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace AllAloneGame
{
public partial class AllAloneLvOne : Form
{
private Image ChrStand = null;
private Image Bg1 = null;
private Image OldManChr = null;
private int ChrXpoint = 1;
private int ChrYpoint = 1; // start point
public int ChrXSpeed;
public int ChrYSpeed;
public int OldManXPoint = 100;
public int OldManYPoint = 50;
public int OldManXSpeed = 10;
public int OldManYSpeed = 10;
public int OldManXSpeed2 = 20;
public int OldManYSpeed2 = 20;
public int OldManPostion = 0;
public AllAloneLvOne()
{
InitializeComponent();
System.Reflection.Assembly ChrObject =
System.Reflection.Assembly.GetExecutingAssembly();
System.Reflection.Assembly Back1 =
System.Reflection.Assembly.GetExecutingAssembly();
System.Reflection.Assembly OldManObject =
System.Reflection.Assembly.GetExecutingAssembly();
ChrStand = new System.Drawing.Bitmap(ChrObject.GetManifestResourceStream("AllAloneGame.StandStillMovement.gif"));
Bg1 = new System.Drawing.Bitmap(Back1.GetManifestResourceStream("AllAloneGame.Background1.gif"));
OldManChr = new System.Drawing.Bitmap(OldManObject.GetManifestResourceStream("AllAloneGame.OldMan.gif"));
}
private void AllAloneLvOne_KeyDown_1(object sender, KeyEventArgs e)
{
if ((e.KeyCode == System.Windows.Forms.Keys.Up))
{
ChrYpoint -= ChrYSpeed = 10;
Invalidate();
}
if ((e.KeyCode == System.Windows.Forms.Keys.Down))
{
ChrYpoint += ChrYSpeed = 10;
Invalidate();
}
if ((e.KeyCode == System.Windows.Forms.Keys.Left))
{
ChrXpoint -= ChrXSpeed = 10;
Invalidate();
}
if ((e.KeyCode == System.Windows.Forms.Keys.Right))
{
ChrXpoint += ChrXSpeed = 10;
Invalidate();
}
if ((e.KeyCode == System.Windows.Forms.Keys.Enter))
{
// Enter
}
}
private void BackGround1_Click(object sender, EventArgs e)
{
}
private void AllAloneLvOne_Paint_1(object sender, PaintEventArgs e)
{
e.Graphics.DrawImage(Bg1, 0, 0);
e.Graphics.DrawImage(ChrStand, ChrXpoint, ChrYpoint);
e.Graphics.DrawImage(OldManChr,OldManXPoint,OldManYPoint);
}
private void GameTimer_Tick(object sender, EventArgs e)
{
OldManYPoint += OldManYSpeed;
GameTimer2.Enabled = true;
Invalidate();
}
private void AllAloneLvOne_Load(object sender, EventArgs e)
{
GameTimer.Enabled = true;
}
private void GameTimer2_Tick(object sender, EventArgs e)
{
GameTimer.Enabled = false;
OldManYPoint -= OldManYSpeed2;
Invalidate();
GameTimer.Enabled = true;
}
}}